ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 29 Aug 2010 15:58:44 +0200What's a good way to track spawned time on a shared server?https://ask.sagemath.org/question/7649/whats-a-good-way-to-track-spawned-time-on-a-shared-server/Sometimes I'm running more than one notebook at a time; and since %time sometimes puts almost everything into Wall Time when I'm mostly using subprocesses, the Wall Time doesn't give me a good picture of the time spent since multiple notebooks are running. How can I work around this measurement problem?Sun, 29 Aug 2010 05:02:21 +0200https://ask.sagemath.org/question/7649/whats-a-good-way-to-track-spawned-time-on-a-shared-server/Answer by Mike Hansen for <p>Sometimes I'm running more than one notebook at a time; and since %time sometimes puts almost everything into Wall Time when I'm mostly using subprocesses, the Wall Time doesn't give me a good picture of the time spent since multiple notebooks are running. How can I work around this measurement problem?</p>
https://ask.sagemath.org/question/7649/whats-a-good-way-to-track-spawned-time-on-a-shared-server/?answer=11589#post-id-11589I think the best way to track time across subprocesses is to use the `cputime` command in Sage. It takes a keyword arguments `subprocesses=True` which will try to track the time spent in subprocesses.
sage: t = cputime(subprocesses=True);
sage: integrate(sin(log(x))^2, x)
-1/5*x*sin(2*log(x)) - 1/10*x*cos(2*log(x)) + 1/2*x
sage: cputime(subprocesses=True) - t
0.13
Compare this with the non- `subprocesses=True` version:
sage: t = cputime();
sage: integrate(sin(log(x))^2, x)
-1/5*x*sin(2*log(x)) - 1/10*x*cos(2*log(x)) + 1/2*x
sage: cputime() - t
0.0099999999999997868
This currently works by using thing `cputime` method on expect interface objects.
Sun, 29 Aug 2010 15:46:25 +0200https://ask.sagemath.org/question/7649/whats-a-good-way-to-track-spawned-time-on-a-shared-server/?answer=11589#post-id-11589Comment by ccanonc for <p>I think the best way to track time across subprocesses is to use the <code>cputime</code> command in Sage. It takes a keyword arguments <code>subprocesses=True</code> which will try to track the time spent in subprocesses.</p>
<pre><code>sage: t = cputime(subprocesses=True);
sage: integrate(sin(log(x))^2, x)
-1/5*x*sin(2*log(x)) - 1/10*x*cos(2*log(x)) + 1/2*x
sage: cputime(subprocesses=True) - t
0.13
</code></pre>
<p>Compare this with the non- <code>subprocesses=True</code> version:</p>
<pre><code>sage: t = cputime();
sage: integrate(sin(log(x))^2, x)
-1/5*x*sin(2*log(x)) - 1/10*x*cos(2*log(x)) + 1/2*x
sage: cputime() - t
0.0099999999999997868
</code></pre>
<p>This currently works by using thing <code>cputime</code> method on expect interface objects.</p>
https://ask.sagemath.org/question/7649/whats-a-good-way-to-track-spawned-time-on-a-shared-server/?comment=22794#post-id-22794Thanks Mike! Great answer as usual. I am finding the multiprocessing and itertools python modules very useful.Sun, 29 Aug 2010 15:58:44 +0200https://ask.sagemath.org/question/7649/whats-a-good-way-to-track-spawned-time-on-a-shared-server/?comment=22794#post-id-22794