469,923 Members | 1,298 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,923 developers. It's quick & easy.

measure module running time


How can I know a module take how much time? Thanks for any hints.

Regards,
Yang

Jul 18 '05 #1
1 2308
| 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

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Grant D. Watson | last post: by
6 posts views Thread by cranium.2003 | last post: by
6 posts views Thread by Charles M. Reinke | last post: by
5 posts views Thread by Larry Bird | last post: by
3 posts views Thread by =?ISO-8859-1?Q?Gregory_Pi=F1ero?= | last post: by
1 post views Thread by David Hirschfield | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.