measure module running time
CousinStanley at hotmail.com
Fri Mar 26 00:14:51 CET 2004
| How can I know a module take how much time? Thanks for any hints.
One simple method is to use the time module
and call the time() function before and after
the block of code that you want to check ....
beg = time.time()
nLoops = 100000
for i in range( nLoops ) :
i += 1
end = time.time()
dt = end - beg
print '\n nLoops : %d, took %9.6f Seconds' % ( nLoops , dt )
Also, for Python 2.3 there is a timeit module
that is a bit more sophisticated ....
help( timeit )
More information about the Python-list