[BangPypers] Place the timer in Python script
anand.shashwat at gmail.com
Fri Sep 18 13:52:06 CEST 2009
One really simple way is to do :
$ time code.py
Works for me for simple codes. For accuracy there is timeit :)
On Fri, Sep 18, 2009 at 4:02 PM, Vishal <vsapre80 at gmail.com> wrote:
> On Fri, Sep 18, 2009 at 3:43 PM, steve <steve at lonetwin.net> wrote:
>> On 09/18/2009 03:33 PM, Vamsi wrote:
>>> How to place the timer in python code.
>>> I want calculate the python script execution time.
>>> ex : Start Timer
>>> : End Timer
>>> Execution Time : End Timer - Start Timer.
>>> How can we write the python code for this.
>> Specifically, the timeit module
>> btw, dunno if you'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's name. It's something like golgol or some such.
>> - steve
>> random non tech spiel: http://lonetwin.blogspot.com/
>> tech randomness: http://lonehacks.blogspot.com/
>> what i'm stumbling into: http://lonetwin.stumbleupon.com/
>> BangPypers mailing list
>> BangPypers at python.org
> Here's what I usually do on windows:
> from time import clock, strftime, gmtime
> start = clock()
> ... do you work here...
> end = clock()
> elapsed = end - start
> print "Time Taken to finish: %s" % (strftime("%Hhrs: %Mmins: %ssecs",
> If you wish to record in miliseconds, you'll have to do some math on the
> 'elapsed' value.
> Thanks and best regards,
> Vishal Sapre
> "So say...Day by day, in every way, I am getting better, better and better
> "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"
> "Diamond is another piece of coal that did well under pressure”
> "Happiness keeps u Sweet, Trials keep u Strong,
> Sorrow keeps u Human, Failure Keeps u Humble,
> Success keeps u Glowing, But only God Keeps u Going.....Keep Going....."
> BangPypers mailing list
> BangPypers at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the BangPypers