calculating system clock resolution

MrJean1 MrJean1 at gmail.com
Fri Apr 7 17:15:27 EDT 2006


Depends .... iff you are using Linux, print

  cat  /proc/cpuinfo

and look for the line "cpu ...Hz: ...".  Parsing that would be
straightforward.

Keep in mind, the time.time() function reports the "wall clock" time,
which usually has up to a millisecond resolution, regardless of the CPU
speed.

There is also time.clock(), more about that on
<http://docs.python.org/lib/module-time.html>

/Jean Brouwers


jUrner at arcor.de wrote:
> Hello all
>
> I have the problem of how to calculate the resolution of the system
> clock.
> Its now two days of head sratching and still there is nothing more than
> these few lines on my huge white sheet of paper stiring at me. Lame I
> know.
>
> import time
>
> t1 = time.time()
> while True:
>     t2 = time.time()
>     if t2 > t1:
>         print t1, t2
>         # start calculating here
>         break
>
>
> BTW t1 and t2 print out equal up to the fraction on my machine. What
> does
> python know that I don't? A pointer to the source lines where this is
> implemented
> would even be helpfull to clear this out. Can't seem to find it.
> 
> Anyone any ideas?




More information about the Python-list mailing list