How to measure elapsed time under Windows?

Grant Edwards invalid at invalid.invalid
Tue Feb 9 16:19:05 EST 2010


On 2010-02-09, Grant Edwards <invalid at invalid.invalid> wrote:
> On 2010-02-09, Jean-Michel Pichavant <jeanmichel at sequans.com> wrote:

>> Did you try with the datetime module ?
>
> No.  What mechanism does it use to get the current date/time?
>
>> import datetime
>> t0 = datetime.datetime.now()
>> t1 = t0 - datetime.datetime.now()
>> t1.microseconds
>> Out[4]: 644114
>
> That looks very broken to me.  I need to measure stuff in the
> 1-20ms range, and the smallest value you can measure using the
> method above appears to be 640ms.  Thats almost 2/3 of a second.

Duh.  It just occurred to me that was done interactively.  I'll
give the datetime module a try once I reboot my test machine
back into Windows.

-- 
Grant Edwards                   grante             Yow! Is this sexual
                                  at               intercourse yet??  Is it,
                               visi.com            huh, is it??



More information about the Python-list mailing list