STINNER Victor added the comment:

Reading directly the CPU timestamp counter is not a good idea.

> One issue with using timestamp counters is that their resolution varies
> with CPU speed, which is not necessarily constant during a whole run
> (because of power management). On the other hand I'm not sure it's
> really a problem.

There is another major issue: you have to synchronize the counter of all CPU 
cores. Windows XP didn't synchronize the counters, and it was a major issue on 
QueryPerformanceCounter.
http://support.microsoft.com/?id=896256

It is really better to rely on the OS rather than querying directly the 
hardward. The OS (well, most OS except Windows) handles all these minor "nits" 
and provide the best possible resolution.

--

> Python 3.3 has a new time.perf_counter() function.
> It may be possible to expose this function in C ...

Oh, I now remember why I didn't do this before: when clock_gettime() function 
is used in perf_counter(), the program or library must be linked to librt on 
most Linux distro. It was easier to only handle this correctly for the time 
module. We can do something similar on the _lsprof module.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue2281>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to