> On 3/27/07, Joel B. Mohler <[EMAIL PROTECTED]> wrote:
> P.S.: Speed comparisons (all on sage.math).  I've included the basic integer

In all your timings below that involve a constant (e.g., 1 or 2), you
should factor
out the constant from the test.  E.g., do a = 1; b = 2; then do the
test with a and b.
Otherwise the Integer( ) function is being called every time on a Python int,
and you're (1) testing the wrong thing, and (2) testing something that won't
reflect how actual code will behave.

Having the preparser factor out constants could be done, and will be someday,
at least for .sage files.

\>
> [EMAIL PROTECTED]:~$ magma
> Magma V2.13-5     Tue Mar 27 2007 07:12:02 on sage     [Seed = 1950028839]
> Type ? for help.  Type <Ctrl>-D to quit.
> > C<I>:=QuadraticField(-1);
> > time for x in [1..100000] do a:=I*I; end for;
> Time: 0.260
> > time for x in [1..100000] do a:=I/2; end for;
> Time: 0.370
> > time for x in [1..100000] do a:=1+1; end for;
> Time: 0.020
>
> sage: C.<I>=QuadraticField(-1)
> sage: time for i in xrange(100000): a=I*I
> CPU times: user 1.79 s, sys: 0.03 s, total: 1.82 s
> Wall time: 1.82
> sage: time for i in xrange(100000): a=I/2
> CPU times: user 10.24 s, sys: 0.12 s, total: 10.37 s
> Wall time: 10.37
> sage: time for i in xrange(100000): a=1+1
> CPU times: user 0.27 s, sys: 0.00 s, total: 0.27 s
> Wall time: 0.27
>
> >
>


-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://www.williamstein.org

--~--~---------~--~----~------------~-------~--~----~
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