Calculating Elapsed Time

Fredrik Lundh fredrik at pythonware.com
Wed Dec 7 13:09:01 EST 2005


Grant Edwards wrote:

> > Yeah, I said it was silly.  On the other hand, the Linux box is a lot faster
> > than the Windows box I'm using, and I do get the same result no matter
> > what Python version I'm using...

except if I run it under my latest 2.4 build, where I get 524288 ...

> >
> > (and in this context, neither 262144 nor 1789772 are random numbers...)
>
> 262144 is 3.8us.  That seems pretty large.  What do you get
> when you do this:
>
> import time
> for i in range(10):
>     print time.time()-time.time()
>
> After the first loop, I usually get one of three values:
>
>   3.099us, 2.14,us, 2.86us.

I get two different values:

-1.90734863281e-06
-2.14576721191e-06

on this hardware (faster than the PC I'm using right now, but still not a
very fast machine).  let's check a faster linux box:

$ python2.4 test.py
-6.91413879395e-06
-1.90734863281e-06
-1.90734863281e-06
-1.90734863281e-06
-1.90734863281e-06
-2.14576721191e-06
-1.90734863281e-06
-2.14576721191e-06
-1.90734863281e-06
-1.90734863281e-06

if I keep running the script over and over again, I do get individual

-1.19209289551e-06

items from time to time on both machines...

</F>






More information about the Python-list mailing list