ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 09 Sep 2013 23:37:45 -0500Fastest way of running sage?http://ask.sagemath.org/question/10525/fastest-way-of-running-sage/Hi,
So far I have used 3 different "versions" of sage:
1. the online sage notebook: http://www.sagenb.org/
2. the sage notebook that I downloaded and run on Windows 7 thru VirtualBox on an intel core 2duo
3. the sage in the cloud found here: https://cloud.sagemath.com/
Using "time a = factorial(1000000)" I get cpu and wall times of(.41s, .41s) for 1 and 2,13s; 9.53s) for 2. For 3 "time" apparently does not work but it seems slower than 1.
Questions:
Why is 1 significantly faster than 2?
How can I test 3?
Is there a way to test entire programs that gives the time for every step.
What is the fastest way to run sage?
Thanks!
Sun, 08 Sep 2013 11:28:34 -0500http://ask.sagemath.org/question/10525/fastest-way-of-running-sage/Answer by tmonteil for <p>Hi,</p>
<p>So far I have used 3 different "versions" of sage:</p>
<ol>
<li><p>the online sage notebook: <a href="http://www.sagenb.org/">http://www.sagenb.org/</a></p></li>
<li><p>the sage notebook that I downloaded and run on Windows 7 thru VirtualBox on an intel core 2duo</p></li>
<li><p>the sage in the cloud found here: <a href="https://cloud.sagemath.com/">https://cloud.sagemath.com/</a></p></li>
</ol>
<p>Using "time a = factorial(1000000)" I get cpu and wall times of(.41s, .41s) for 1 and 2,13s; 9.53s) for 2. For 3 "time" apparently does not work but it seems slower than 1.</p>
<p>Questions:
Why is 1 significantly faster than 2?</p>
<p>How can I test 3?</p>
<p>Is there a way to test entire programs that gives the time for every step.</p>
<p>What is the fastest way to run sage?</p>
<p>Thanks!</p>
http://ask.sagemath.org/question/10525/fastest-way-of-running-sage/?answer=15438#post-id-15438As suggested by @fidbc, it is very likely that your second test is much slower than the other ones because of the following heavy stack: Sage runs on Linux which is emulated by virtualbox which runs on windows! This may also explain why, in this second case, the wall time is much bigger than the CPU time: the wall time also counts the time spent for letting the stack work and the communications among parts of the stack.
Also, this might be due to the fact that an external greedy process in running during your test. To circumvent this possibility, you can use `%timeit` instead of `%time`: your test will be run several times and will select the fastest one.
If you want to run Sage on your local machine, i strongly advise to install Linux on an additionnal partition and run Sage directly from it. A lighter solution could be to boot from a [live USB key that includes Sage](http://wiki.sagemath.org/SageLiveUSB). If you make some tests with those configurations, i would like to see the difference.
If you are interested in saving time without much coding effort, you may be interested in the [@parallel decorator](http://www.sagemath.org/doc/reference/parallel/sage/parallel/decorate.html).
Mon, 09 Sep 2013 23:37:45 -0500http://ask.sagemath.org/question/10525/fastest-way-of-running-sage/?answer=15438#post-id-15438Answer by fidbc for <p>Hi,</p>
<p>So far I have used 3 different "versions" of sage:</p>
<ol>
<li><p>the online sage notebook: <a href="http://www.sagenb.org/">http://www.sagenb.org/</a></p></li>
<li><p>the sage notebook that I downloaded and run on Windows 7 thru VirtualBox on an intel core 2duo</p></li>
<li><p>the sage in the cloud found here: <a href="https://cloud.sagemath.com/">https://cloud.sagemath.com/</a></p></li>
</ol>
<p>Using "time a = factorial(1000000)" I get cpu and wall times of(.41s, .41s) for 1 and 2,13s; 9.53s) for 2. For 3 "time" apparently does not work but it seems slower than 1.</p>
<p>Questions:
Why is 1 significantly faster than 2?</p>
<p>How can I test 3?</p>
<p>Is there a way to test entire programs that gives the time for every step.</p>
<p>What is the fastest way to run sage?</p>
<p>Thanks!</p>
http://ask.sagemath.org/question/10525/fastest-way-of-running-sage/?answer=15434#post-id-15434Hi,
(This was just going to be a comment but it got too long)
1. Maybe 1 is faster than 2 since that is running natively on the server, the VirtualBox overhead might slow things down.
2. You can create a worksheet and run the command
%time a=factorial(1000000)
Here is what I got.
![image description](/upfiles/13786789568663543.png)
3. On profiling programs:
sage: %prun a=factorial(1000000)
2 function calls in 0.286 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.286 0.286 0.286 0.286 0.286 <string>:1(<module>)
1 0.000 0.000 0.000 0.000 {method 'disable' of _lsprof.Profiler' objects}
More details [here](http://www.sagemath.org/doc/tutorial/programming.html#profiling).
4. Perhaps the naive answer is that running it on a "faster" computer would do the job. ;-) My experience back around sage-4.x was that compiling it resulted in faster runs, so my recommendation would be to compile sage on a linux machine.
Just ran the factorial command and got
sage: %time a=factorial(1000000)
CPU times: user 0.27 s, sys: 0.01 s, total: 0.28 s
Wall time: 0.28 s
I'm running a compiled sage 5.10 on arch linux.
Hope it helps!
---
Updated to include running time at cloud.sagemath.org
Sun, 08 Sep 2013 12:07:18 -0500http://ask.sagemath.org/question/10525/fastest-way-of-running-sage/?answer=15434#post-id-15434Comment by Alexandru Papiu for <p>Hi,</p>
<p>(This was just going to be a comment but it got too long)</p>
<ol>
<li><p>Maybe 1 is faster than 2 since that is running natively on the server, the VirtualBox overhead might slow things down.</p></li>
<li><p>You can create a worksheet and run the command</p>
<pre><code>%time a=factorial(1000000)
</code></pre>
<p>Here is what I got.
<img alt="image description" src="/upfiles/13786789568663543.png"/></p></li>
<li><p>On profiling programs:</p>
<pre><code>sage: %prun a=factorial(1000000)
2 function calls in 0.286 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.286 0.286 0.286 0.286 0.286 <string>:1(<module>)
1 0.000 0.000 0.000 0.000 {method 'disable' of _lsprof.Profiler' objects}
</code></pre>
<p>More details <a href="http://www.sagemath.org/doc/tutorial/programming.html#profiling">here</a>.</p></li>
<li><p>Perhaps the naive answer is that running it on a "faster" computer would do the job. ;-) My experience back around sage-4.x was that compiling it resulted in faster runs, so my recommendation would be to compile sage on a linux machine.</p>
<p>Just ran the factorial command and got</p>
<pre><code>sage: %time a=factorial(1000000)
CPU times: user 0.27 s, sys: 0.01 s, total: 0.28 s
Wall time: 0.28 s
</code></pre>
<p>I'm running a compiled sage 5.10 on arch linux.</p></li>
</ol>
<p>Hope it helps!</p>
<hr/>
<p>Updated to include running time at <a href="http://cloud.sagemath.org">cloud.sagemath.org</a></p>
http://ask.sagemath.org/question/10525/fastest-way-of-running-sage/?comment=17026#post-id-17026Thanks you, this is really helpful!Mon, 09 Sep 2013 11:28:44 -0500http://ask.sagemath.org/question/10525/fastest-way-of-running-sage/?comment=17026#post-id-17026