[sage-devel] Re: Benchmark in Sage

2013-08-02 Thread Volker Braun
timeit() repeats the benchmark a number of times and prints the best time. 
Sometimes the run time is slower because of background processes, and the 
best time over all loops is a reasonably stable measure of how fast the 
code really is. The number of loops is just for your information; tests 
that take longer are run less often to keep the overall run time bounded. 
See also

sage: timeit?


On Friday, August 2, 2013 12:02:29 PM UTC-4, Verónica Suaste wrote:
>
> Thank's both for your answer!
>
> Still I have some questions. Probably I'm not understanding what exactly 
> means the first data: the number of loops and how should I consider this.
> For example if I get the next output for two different functions that I'm 
> trying to compare:
> 1 loops, best of 3: 36.4 ms per loop
> 10 loops, best of 3: 34.6 ms per loop
> I would say that the second one is slower because it has to do more loops 
> and the time per loop in each one is almost the same. is that correct?
> Another question: there is some paremeter for %timeit that returns the 
> output in seconds,as for timeit you can do:
> sage:timeit('1+1',seconds = True) 
> 
>
> 5.329132080078125e-07   
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.




[sage-devel] Re: Benchmark in Sage

2013-08-02 Thread Verónica Suaste
Thank's both for your answer!

Still I have some questions. Probably I'm not understanding what exactly 
means the first data: the number of loops and how should I consider this.
For example if I get the next output for two different functions that I'm 
trying to compare:
1 loops, best of 3: 36.4 ms per loop
10 loops, best of 3: 34.6 ms per loop
I would say that the second one is slower because it has to do more loops 
and the time per loop in each one is almost the same. is that correct?
Another question: there is some paremeter for %timeit that returns the 
output in seconds,as for timeit you can do:
sage:timeit('1+1',seconds = True)   

 
5.329132080078125e-07   


-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.




[sage-devel] Re: Benchmark in Sage

2013-08-01 Thread Harald Schilly

Hi, it's better to use timeit, or in a sage cell, e.g. "%timeit 
function(arg)"
The question you were asking deals more specifically what the computer is 
doing between start and end of the invocation. "wall time" is like an 
absolute clock on the wall, "sys time" the amount of computation the system 
had to do (disk, i/o activity, ... these operations halt your actual 
computation because they have to wait for new data), and the cpu time is 
what the cpu actually had to do. 

h

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.




[sage-devel] Re: Benchmark in Sage

2013-07-31 Thread Volker Braun
Use timeit to benchmark:

sage: timeit('1+1')
625 loops, best of 3: 729 ns per loop

"man time" will explain real/user/sys if you want to know:

   The  time  command  runs  the specified program command with the 
given arguments.  When command
   finishes, time writes a message to standard error giving timing 
statistics about  this  program
   run.  These statistics consist of (i) the elapsed real time between 
invocation and termination,
   (ii) the user CPU time (the sum of the tms_utime and tms_cutime 
 values  in  a  struct  tms  as
   returned  by  times(2)), and (iii) the system CPU time (the sum of 
the tms_stime and tms_cstime
   values in a struct tms as returned by times(2)).

 

On Wednesday, July 31, 2013 10:33:07 PM UTC-4, Verónica Suaste wrote:
>
> Hi,
>
> I want to compare different algorithms in terms of time. 
> When I put %time I get these three data as output CPU times, sys and wall 
> time. Somebody can explain me(or suggest a link) what it means each one, 
> and how should I consider each one for comparisson? 
>
> Thanks!
> Verónica
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.




[sage-devel] Re: Benchmark Document

2009-04-09 Thread Jason Grout

William Stein wrote:
> On Wed, Apr 8, 2009 at 2:16 PM, William Stein  wrote:
>> On Wed, Apr 8, 2009 at 2:11 PM, ahmet alper parker  
>> wrote:
>>> Hello Everybody,
>>> Is there any document that compares Matlab, Mathematica and Sage (Plus all
>>> the contributing codes, in example Maxima, etc.) functions, properties,
>>> toolboxes?
>>> In example,
>>>   Matlab Mathematica   Sage Platform
>>> NewtonMethod  Yes  Yes   Yes
>>> Modified Newton No   Yes  Yes
>>>
>>> If not, it will be very good to compare them for marketing purposes. Most
>>> people don't use highly detailed methods/toolboxes of commercial
>>> applications, and if they know at least Sage can provide them what they need
>>> to a certain level, they would choose Sage.
>>> Regards
>>> AAP
>> There is no such document.
>>
> 
> However, we did start something related to this for Magma:
> 
> http://wiki.sagemath.org/magma
> 
> The goal there is mainly to list things Magma can do but Sage can't.
> 
> William


I also started something like this to compare Mathematica graph theory 
stuff with Sage stuff.  It's a little out of date now.

http://wiki.sagemath.org/CombinatoricaCompare

Jason


--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Benchmark Document

2009-04-08 Thread William Stein

On Wed, Apr 8, 2009 at 2:16 PM, William Stein  wrote:
> On Wed, Apr 8, 2009 at 2:11 PM, ahmet alper parker  wrote:
>> Hello Everybody,
>> Is there any document that compares Matlab, Mathematica and Sage (Plus all
>> the contributing codes, in example Maxima, etc.) functions, properties,
>> toolboxes?
>> In example,
>>           Matlab Mathematica   Sage Platform
>> NewtonMethod      Yes  Yes   Yes
>> Modified Newton No   Yes  Yes
>>
>> If not, it will be very good to compare them for marketing purposes. Most
>> people don't use highly detailed methods/toolboxes of commercial
>> applications, and if they know at least Sage can provide them what they need
>> to a certain level, they would choose Sage.
>> Regards
>> AAP
>
> There is no such document.
>

However, we did start something related to this for Magma:

http://wiki.sagemath.org/magma

The goal there is mainly to list things Magma can do but Sage can't.

William

--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Benchmark Document

2009-04-08 Thread William Stein

On Wed, Apr 8, 2009 at 2:11 PM, ahmet alper parker  wrote:
> Hello Everybody,
> Is there any document that compares Matlab, Mathematica and Sage (Plus all
> the contributing codes, in example Maxima, etc.) functions, properties,
> toolboxes?
> In example,
>           Matlab Mathematica   Sage Platform
> NewtonMethod      Yes  Yes   Yes
> Modified Newton No   Yes  Yes
>
> If not, it will be very good to compare them for marketing purposes. Most
> people don't use highly detailed methods/toolboxes of commercial
> applications, and if they know at least Sage can provide them what they need
> to a certain level, they would choose Sage.
> Regards
> AAP

There is no such document.

William

--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Benchmark

2007-01-25 Thread Bill Hart

Some code for doing this was contributed to FLINT a while back. It will
be fast, when we eventually get it incorporated properly in FLINT. It's
been sitting in my inbox for some time and isn't even in the svn
repository for FLINT yet. I don't have benchmarks to give at present,
but I'll let you know when we do.

Bill.

On 23 Jan, 23:12, "William Stein" <[EMAIL PROTECTED]> wrote:
> On Tue, 23 Jan 2007 14:09:56 -0800, Kiran S. Kedlaya <[EMAIL PROTECTED]> 
> wrote:
>
>
>
> > Here's a benchmark I just tried, which annoys me.
>
> > sage: def test1():
> > : P. = PolynomialRing(RationalField())
> > : t = x^8 - 11*x^7 + x^5 - 1
> > : for _ in xrange(1000):
> > : t.complex_roots()
> > :
> > sage: time test1()
> > CPU times: user 6.78 s, sys: 0.02 s, total: 6.80 s
> > Wall time: 6.80
> > sage: def test2():
> > : t = pari("x^8 - 11*x^7 + x^5 - 1")
> > : for _ in xrange(1000):
> > :  t.polroots()
> > :
> > sage: time test2()
> > CPU times: user 6.15 s, sys: 0.00 s, total: 6.15 s
> > Wall time: 6.15
> > sage: %magma
> > magma: procedure test3()
> > magma: P := PolynomialRing(RealField(53));
> > magma: u := x^8 - 11*x^7 + x^5 - 1;
> > magma: for i := 1 to 1000 do
> > magma: t := Roots(u);
> > magma: end for;
> > magma: end procedure;
> > magma: time test3();
> >  Time: 1.200
>
> > The thing that bugs me is that Magma does not have some fancy
> > proprietary algorithm for finding roots of a univariate polynomial; it
> > uses PARI! So why are we so much slower?Why do you think MAGMA uses PARI 
> > for this?  (And this isn't so much
> a problem with SAGE but with PARI  Try the same computation
> directly in PARI and it is just as slow.)
>
> If you really want the answer to only 53-bits precision, by the way,
> numpy can do it much much faster than MAGMA. For example,
>
> sage: import numpy
> sage: f = numpy.array([1,-11,0,1,0,0,0,0,-1]))
> sage: numpy.roots(f)
> sage: array([ 10.99172314+0.j,  -0.72174425+0.j,
>  -0.45332013+0.53432014j,  -0.45332013-0.53432014j,
>   0.66182264+0.30451078j,   0.66182264-0.30451078j,
>   0.15650805+0.67766101j,   0.15650805-0.67766101j])
> sage: time v=[numpy.roots(f) for _ in range(1000)]
> CPU times: user 0.28 s, sys: 0.00 s, total: 0.28 s
> Wall time: 0.28
>
> That's already about 5 times faster than MAGMA.  And I bet
> that on larger degree numpy beats MAGMA by a lot more...
>
> SAGE doesn't use numpy for root finding yet, partly because
> numpy was added to SAGE only very recently, and I haven't
> touched the root finding code in a while.
> 
> I've made this trac ticket #211.
> 
> William


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



[sage-devel] Re: Benchmark

2007-01-23 Thread William Stein

On Tue, 23 Jan 2007 14:09:56 -0800, Kiran S. Kedlaya <[EMAIL PROTECTED]> wrote:

> Here's a benchmark I just tried, which annoys me.
>
> sage: def test1():
> : P. = PolynomialRing(RationalField())
> : t = x^8 - 11*x^7 + x^5 - 1
> : for _ in xrange(1000):
> : t.complex_roots()
> :
> sage: time test1()
> CPU times: user 6.78 s, sys: 0.02 s, total: 6.80 s
> Wall time: 6.80
> sage: def test2():
> : t = pari("x^8 - 11*x^7 + x^5 - 1")
> : for _ in xrange(1000):
> :  t.polroots()
> :
> sage: time test2()
> CPU times: user 6.15 s, sys: 0.00 s, total: 6.15 s
> Wall time: 6.15
> sage: %magma
> magma: procedure test3()
> magma: P := PolynomialRing(RealField(53));
> magma: u := x^8 - 11*x^7 + x^5 - 1;
> magma: for i := 1 to 1000 do
> magma: t := Roots(u);
> magma: end for;
> magma: end procedure;
> magma: time test3();
>  Time: 1.200
>
> The thing that bugs me is that Magma does not have some fancy
> proprietary algorithm for finding roots of a univariate polynomial; it
> uses PARI! So why are we so much slower?

Why do you think MAGMA uses PARI for this?  (And this isn't so much
a problem with SAGE but with PARI  Try the same computation
directly in PARI and it is just as slow.)

If you really want the answer to only 53-bits precision, by the way,
numpy can do it much much faster than MAGMA. For example,

sage: import numpy
sage: f = numpy.array([1,-11,0,1,0,0,0,0,-1]))
sage: numpy.roots(f)
sage: array([ 10.99172314+0.j,  -0.72174425+0.j,
 -0.45332013+0.53432014j,  -0.45332013-0.53432014j,
  0.66182264+0.30451078j,   0.66182264-0.30451078j,
  0.15650805+0.67766101j,   0.15650805-0.67766101j])
sage: time v=[numpy.roots(f) for _ in range(1000)]
CPU times: user 0.28 s, sys: 0.00 s, total: 0.28 s
Wall time: 0.28

That's already about 5 times faster than MAGMA.  And I bet
that on larger degree numpy beats MAGMA by a lot more...

SAGE doesn't use numpy for root finding yet, partly because
numpy was added to SAGE only very recently, and I haven't
touched the root finding code in a while.

I've made this trac ticket #211.

William

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