Issue #14428, #14397: Implement the PEP 418

* Rename time.steady() to time.monotonic()
 * On Windows, time.monotonic() uses GetTickCount/GetTickCount64() instead of
   QueryPerformanceCounter()
 * time.monotonic() uses CLOCK_HIGHRES if available
 * Add time.get_clock_info(), time.perf_counter() and time.process_time()
   functions
This commit is contained in:
Victor Stinner 2012-04-29 02:41:27 +02:00
parent ca6e40f12a
commit ec89539ccc
9 changed files with 729 additions and 133 deletions

View file

@ -22,11 +22,25 @@ typedef struct {
} _PyTime_timeval;
#endif
/* Structure used by time.get_clock_info() */
typedef struct {
const char *implementation;
int is_monotonic;
int is_adjusted;
double resolution;
} _Py_clock_info_t;
/* Similar to POSIX gettimeofday but cannot fail. If system gettimeofday
* fails or is not available, fall back to lower resolution clocks.
*/
PyAPI_FUNC(void) _PyTime_gettimeofday(_PyTime_timeval *tp);
/* Similar to _PyTime_gettimeofday() but retrieve also information on the
* clock used to get the current time. */
PyAPI_FUNC(void) _PyTime_gettimeofday_info(
_PyTime_timeval *tp,
_Py_clock_info_t *info);
#define _PyTime_ADD_SECONDS(tv, interval) \
do { \
tv.tv_usec += (long) (((long) interval - interval) * 1000000); \