calculating system clock resolution
Steven D'Aprano
steve at REMOVETHIScyber.com.au
Sat Apr 8 03:50:57 EDT 2006
Ah, drat -- hit the wrong key and sent the last post before I had finished
writing it... the following is what I *intended* to send.
On Fri, 07 Apr 2006 16:39:40 -0700, jUrner wrote:
> Maybe it was not too clear what I was trying to point out.
>
> I have to calculate the time time.time() requires to return the next
> tick of the clock.
> Should be about 0.01ms but this may differ from os to os.
I suspect that Python isn't quite fast enough to give an accurate measure
for this, but I could be wrong.
You can try this:
def calc_time_res():
now = time.time
start = now()
x = start
while start == x:
x = now()
print x - start
Trying it, I get a fairly small number:
>>> calc_time_res()
1.50203704834e-05
>>> calc_time_res()
1.50203704834e-05
>>> calc_time_res()
1.50203704834e-05
This is Python 2.3 running under Fedora Core 2 Linux.
--
Steven.
More information about the Python-list
mailing list