High-resolution timers
Michael Hudson
mwh at python.net
Wed Jan 16 11:29:28 EST 2002
Bryan <bryan at eevolved.com> writes:
> I understand that the precision of the timer is
> hardware-dependent... But can someone give me an example of a
> platform on which time.time() has a resolution of less than 1
> millisecond ?
Windows:
>>> d = {}
>>> for i in range(100000):
d[time.time()] = 1
>>> len(d)
51
>>> l = d.keys()
>>> l.sort()
>>> for i in range(len(l) - 1):
print l[i+1] - l[i],
0.0110000371933 0.00999999046326 0.00999999046326 0.00999999046326
0.00999999046326 0.00999999046326 0.00999999046326 0.00999999046326
0.00999999046326 0.0100001096725 0.00999999046326 0.00999999046326
0.00999999046326 0.00999999046326 0.00999999046326 0.00999999046326
0.00999999046326 0.00999999046326 0.00999999046326 0.00999999046326
0.00999999046326 0.0100001096725 0.00999999046326 0.00999999046326
0.00999999046326 0.00999999046326 0.00999999046326 0.00999999046326
0.00999999046326 0.00999999046326 0.00999999046326 0.00999999046326
0.00999999046326 0.00999999046326 0.0100001096725 0.00999999046326
0.00999999046326 0.00999999046326 0.00999999046326 0.00999999046326
0.00999999046326 0.00999999046326 0.00999999046326 0.00999999046326
0.00999999046326 0.00999999046326 0.0100001096725 0.00999999046326
0.00999999046326 0.00999999046326
Looks like a resolution of 0.01 to me.
Linux, OTOH:
>>> d = {}
>>> import time
>>> for i in range(1000):
... d[time.time()] = 1
...
>>> len(d)
1000
Cheers,
M.
--
ARTHUR: Ford, you're turning into a penguin, stop it.
-- The Hitch-Hikers Guide to the Galaxy, Episode 2
More information about the Python-list
mailing list