python : timeit - Tool for measuring execution time

Ganesh Pal ganesh1pal at gmail.com
Wed Apr 22 12:50:10 EDT 2015


Thank you ,  this answers my question  : )
On Apr 22, 2015 6:39 PM, "Michael Torrie" <torriem at gmail.com> wrote:
>
> On 04/21/2015 09:31 PM, Ganesh Pal wrote:
> > Iam not able to understand what  why only 10 loops were run ? what
> > does this mean and how  does this work ?
>
> I have a hunch you're mistakenly thinking that Python is only running
> through ten iterations of your for i in range(1000000) loop.  This is
> not the case.  The entire thing is running (all 1000000 iterations of
> your loop), but is run ten times, as that is the default for timeit
> unless you specify that you want to run it more times.  Hope this helps.
>
> Basically timeit is doing something like this:
>
> def mycode():
>     for i in range(1000000):
>         pass
>
> for x in range(10):
>      mycode()
>
> And then collecting timing statistics on the ten passes.
> --
> https://mail.python.org/mailman/listinfo/python-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150422/5a079b65/attachment.html>


More information about the Python-list mailing list