[Python-Dev] this is why we shouldn't call it a "monotonic clock" (was: PEP 418 is too divisive and confusing and should be postponed)

Victor Stinner victor.stinner at gmail.com
Mon Apr 9 13:24:38 CEST 2012


2012/4/9 Guido van Rossum <guido at python.org>:
>>You may need two clocks
>> for this:
>>  * time.perf_counter(): high-resolution timer for benchmarking, count
>> time elasped during a sleep
>>  * time.process_time(): High-resolution (?) per-process timer from the
>> CPU. (other possible names: time.process_cpu_time() or
>> time.cpu_time())
>
> TBH I don't need another timer that measures CPU time (not even on
> Windows). In a sense, measuring CPU time is a relic from the age of
> mainframes and timesharing, where CPU time was the most precious
> resource (and in some cases the unit in which other resources were
> expressed for accounting purposes). In modern days, it's much more
> likely that the time you're measuring is somehow related to how long a
> use has to wait for some result (e.g. web response times) and here
> "wait time" is just as real as CPU time.

Ah. In this case, my initial proposition is correct. I re-added the pseudo-code:
http://www.python.org/dev/peps/pep-0418/#deferred-api-time-perf-counter

Use QueryPerformanceCounter(), or time.monotonic() or time.time().

Victor


More information about the Python-Dev mailing list