By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,547 Members | 1,435 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,547 IT Pros & Developers. It's quick & easy.

measure module running time

P: n/a

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

Regards,
Yang

Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
| 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.