In article <4c5178ae$0$11091$c3e8...@news.astraweb.com>, Steven D'Aprano <st...@remove-this-cybersource.com.au> wrote: >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.
There is an alternative, for once the semicolon comes in handy: >>>from time import * >>> x=time(); function(); print time()-x 6.551980773430 > >The best way to time small code snippets and fast functions is with the >timeit module. > >-- >Steven Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. alb...@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst -- http://mail.python.org/mailman/listinfo/python-list