[Python-Dev] [RFC] PEP 418: Add monotonic time, performance counter and process time functions (original) (raw)
Victor Stinner victor.stinner at gmail.com
Sun Apr 15 17🔞35 CEST 2012
- Previous message: [Python-Dev] [RFC] PEP 418: Add monotonic time, performance counter and process time functions
- Next message: [Python-Dev] [RFC] PEP 418: Add monotonic time, performance counter and process time functions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Here is a simplified version of the first draft of the PEP 418. The full version can be read online. http://www.python.org/dev/peps/pep-0418/
FYI there is no time.thread_time() function. It would only be available on Windows and Linux. It does not use seconds but CPU cycles. No module or program of the Python source code need such function, whereas all other functions added by the PEP already have users in the Python source code, see the Rationale section. For Linux, CLOCK_THREAD_CPUTIME_ID is already available in Python 3.3. For Windows, you can get GetThreadTimes() using ctypes or win32process.
time.processtime() ^^^^^^^^^^^^^^^^^^^
Pseudo-code [#pseudo]::  if os.name == 'nt':  def processtime():  handle = win32process.GetCurrentProcess()  processtimes = win32process.GetProcessTimes(handle)  return (processtimes['UserTime'] + processtimes['KernelTime']) * 1e-7  else:  import os  ...  def processtime():  ...  return time.clock()
Is the C clock() function available on all platforms? timemodule.c checks for HAVE_CLOCK, but test_time checks that time.clock() is defined and does not fail since the changeset 4de05cbf5ad1, Dec 06 1996. If clock() is not available on all platforms, time.process_time() documentation should be fixed.
Victor
- Previous message: [Python-Dev] [RFC] PEP 418: Add monotonic time, performance counter and process time functions
- Next message: [Python-Dev] [RFC] PEP 418: Add monotonic time, performance counter and process time functions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]