Steven D'Aprano <st...@remove-this-cybersource.com.au> writes:

> On Thu, 29 Jul 2010 14:42:58 +0200, Matteo Landi wrote:
>
>> This should be enough
>> 
>>>>>import time
>>>>>tic = time.time()
>>>>>function()
>>>>>toc = time.time()
>>>>>print toc - tic
>
> You're typing that in the interactive interpreter, which means the
> timer is counting the seconds while you're typing subsequent
> commands. At the very least, you need to put that code into a
> function.

Or, trivially improved as follows:

>>> t0 = time.time(); function(); t1 = time.time()
>>> print t1 - t0

This technique, while nowhere nearly as thorough as the timeit module,
still gives useful results for simple measurements.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to