On Monday 18 December 2006 14:06, David Harvey wrote:
> On Dec 18, 2006, at 2:03 PM, Joel B. Mohler wrote:
> > On Monday 18 December 2006 12:28, David Harvey wrote:
> >> Have you tried calling them from within a pyrex loop with a C index
> >> variable?
> >
> > You might want to look pretty carefully at this to see if I'm testing
> > what I
> > hope to be testing.  I guess the question I'm really asking is this:
> > Here we
> > have a very slight improvement.  Is it worth it to make the code
> > harder to
> > read to actually have this improvement?
>
> You need
>
> cdef int i;
>
> otherwise you are using a python integer as the loop variable.

Good point.  Not much difference though:

Revised Code:
    def test_speed( self, rr ):
        import time
        time_time = time.time
        cdef int i
        a = rr(1.2)
        b = rr(3.2938)
        t1 = time_time()
        for i from 0 <= i < 1000000:
            c = a+b
        t2 = time_time()
        print t2 - t1
        cdef sage.rings.real_mpfr.RealNumber _a, _b
        _a = a
        _b = b
        t3 = time_time()
        for i from 0 <= i < 1000000:
            _c = _a._add_c( _b )
        t4 = time_time()
        print t4 - t3

Revised Times:
sage: I.test_speed(RR)
1.48351502419
1.39341783524
sage: I.test_speed(RR)
1.52830004692
1.40666103363
sage: I.test_speed(RR)
1.53452420235
1.40359687805
sage: I.test_speed(RR)
1.52653217316
1.39675307274

Note that time_time is a single python table lookup vs. time.time.  However 
(paradoxically), the times increased for time_time.  These things are weird.

--
Joel

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to