From: Chris Rebert on 16 Jul 2010 21:58 On Fri, Jul 16, 2010 at 5:52 PM, Jia Hu <hujia06(a)gmail.com> wrote: > Hello: > > If I want to calculate the runtime of a section of a program. How can I do > it? Taking you extremely literally: from time import time start = time() run_section_here() end = time() runtime = end-start Assuming you're doing this in order to optimize: http://docs.python.org/library/profile.html Or in particularly simple cases: http://docs.python.org/library/timeit.html Cheers, Chris -- http://blog.rebertia.com
|
Pages: 1 Prev: Subsets of Python implemented in Python Next: Where is a module usually installed? |