One really simple way is to do :<br>$ time code.py<br>Works for me for simple codes. For accuracy there is timeit :)<br><br><div class="gmail_quote">On Fri, Sep 18, 2009 at 4:02 PM, Vishal <span dir="ltr">&lt;<a href="mailto:vsapre80@gmail.com">vsapre80@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="gmail_quote"><div class="im">On Fri, Sep 18, 2009 at 3:43 PM, steve <span dir="ltr">&lt;<a href="mailto:steve@lonetwin.net" target="_blank">steve@lonetwin.net</a>&gt;</span> wrote:<br>
</div><div><div></div><div class="h5"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div>On 09/18/2009 03:33 PM, Vamsi wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
How to place the timer in python code.<br>
<br>
I want calculate the python script execution time.<br>
<br>
ex : Start Timer<br>
      : End Timer<br>
<br>
Execution Time : End Timer - Start Timer.<br>
<br>
How can we write the python code for this.<br>
</blockquote>
</div><a href="http://docs.python.org/library/debug.html" target="_blank">http://docs.python.org/library/debug.html</a><br>
<br>
Specifically, the timeit module<br>
<a href="http://docs.python.org/library/timeit.html" target="_blank">http://docs.python.org/library/timeit.html</a><br>
<br>
btw, dunno if you&#39;ve heard about this really neat web application. It is a simple text box with a couple of buttons that answers questions such as these. I forgot it&#39;s name. It&#39;s something like golgol or some such.<br>



<br>
cheers,<br>
- steve<br><font color="#888888">
<br>
-- <br>
random non tech spiel: <a href="http://lonetwin.blogspot.com/" target="_blank">http://lonetwin.blogspot.com/</a><br>
tech randomness: <a href="http://lonehacks.blogspot.com/" target="_blank">http://lonehacks.blogspot.com/</a><br>
what i&#39;m stumbling into: <a href="http://lonetwin.stumbleupon.com/" target="_blank">http://lonetwin.stumbleupon.com/</a></font><div><div></div><div><br>
_______________________________________________<br>
BangPypers mailing list<br>
<a href="mailto:BangPypers@python.org" target="_blank">BangPypers@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/bangpypers" target="_blank">http://mail.python.org/mailman/listinfo/bangpypers</a><br>
</div></div></blockquote></div></div></div><br><br><div>Here&#39;s what I usually do on windows:</div><div><br></div><div><font face="&#39;courier new&#39;, monospace">from time import clock, strftime, gmtime</font></div>


<div><font face="&#39;courier new&#39;, monospace"><br></font></div><div><font face="&#39;courier new&#39;, monospace">start = clock()</font></div><div><font face="&#39;courier new&#39;, monospace"><br>

</font></div><div><font face="&#39;courier new&#39;, monospace">... do you work here...</font></div><div><font face="&#39;courier new&#39;, monospace"><br></font></div><div>

<font face="&#39;courier new&#39;, monospace">end = clock()</font></div><div><font face="&#39;courier new&#39;, monospace"><br></font></div><div><font face="&#39;courier new&#39;, monospace">elapsed = end - start</font></div>


<div><font face="&#39;courier new&#39;, monospace">print &quot;Time Taken to finish: %s&quot; % (strftime(&quot;%Hhrs: %Mmins: %ssecs&quot;, gmtime(elapsed))</font></div><div><br></div><div>If you wish to record in miliseconds, you&#39;ll have to do some math on the &#39;elapsed&#39; value.</div>


<div><br clear="all"><br>-- <br>Thanks and best regards,<br>Vishal Sapre<br><br>---<br><br>&quot;So say...Day by day, in every way, I am getting better, better and better !!!&quot;<br>&quot;A Strong and Positive attitude creates more miracles than anything else. Because...Life is 10% how you make it, and 90% how you take it&quot;<br>


&quot;Diamond is another piece of coal that did well under pressure”<br>&quot;Happiness keeps u Sweet, Trials keep u Strong, <br>Sorrow keeps u Human, Failure Keeps u Humble, <br>Success keeps u Glowing, But only God Keeps u Going.....Keep Going.....&quot;<br>



</div>
<br>_______________________________________________<br>
BangPypers mailing list<br>
<a href="mailto:BangPypers@python.org">BangPypers@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/bangpypers" target="_blank">http://mail.python.org/mailman/listinfo/bangpypers</a><br>
<br></blockquote></div><br>