[Python-ideas] time.wallclock() or other similar stuff

M.-A. Lemburg mal at egenix.com
Tue Nov 2 10:33:26 CET 2010

Kristján Valur Jónsson wrote:
> Bringing this in from python-dev, and http://bugs.python.org/issue10278
> Summary:  time.clock() means two different things on Windows and Unix.  So, if you need to measure time across a blocking call in a portable way, you need to use time.time() (this fact is not documented).  Time.time has its own problems though, such as low resolution (compared to time.clock on windows) and being susceptible to being adjusted by the user.
> I proposed adding a time.wallclock() to address this issue, which would be the most suitable function for the job on any platform.  The patch is an example implementation.  Any thoughts?  And yes, I acknowledge that the time module is complicated enough as it is :)

You might want to look at the systimes.py module that comes with pybench
(see Tools/pybench). This already provides a cross-platform way of
accessing high accuracy timers for benchmarking and the like.

For obvious reasons this tries to measure run-time, though, and not
elapsed time.

Marc-Andre Lemburg

Professional Python Services directly from the Source  (#1, Nov 02 2010)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/

::: Try our new mxODBC.Connect Python Database Interface for free ! ::::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611

More information about the Python-ideas mailing list