Thank you, it is so straightforward.

On Fri, Jul 16, 2010 at 9:58 PM, Chris Rebert <c...@rebertia.com> wrote:

> On Fri, Jul 16, 2010 at 5:52 PM, Jia Hu <huji...@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
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to