measure module running time
Cousin Stanley
CousinStanley at hotmail.com
Thu Mar 25 18:14:51 EST 2004
| How can I know a module take how much time? Thanks for any hints.
Yang ....
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 ....
import time
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 ....
import timeit
help( timeit )
--
Cousin Stanley
Human Being
Phoenix, Arizona
More information about the Python-list
mailing list