timing
Chris Rebert
clp2 at rebertia.com
Fri Jul 16 21:58:13 EDT 2010
On Fri, Jul 16, 2010 at 5:52 PM, Jia Hu <hujia06 at 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
More information about the Python-list
mailing list