PEP 418: Mention the Technical Q&A QA1398 for mach_absolute_time()

This commit is contained in:
Victor Stinner 2012-03-28 02:59:01 +02:00
parent 02b9a5bcb3
commit aaa1107673
1 changed files with 13 additions and 10 deletions

View File

@ -137,7 +137,7 @@ system time.
It is available on all platforms and cannot fail. It is available on all platforms and cannot fail.
Pseudo-code [#pseudo]_: :: Pseudo-code::
def hires(): def hires():
if hires.use_monotonic: if hires.use_monotonic:
@ -158,11 +158,15 @@ Monotonic
mach_absolute_time mach_absolute_time
^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
Mac OS X provides a monotonic clock: mach_absolute_time(). mach_timebase_info() Mac OS X provides a monotonic clock: mach_absolute_time(). It is based on
provides a fraction to convert the clock value to a number of nanoseconds. absolute elapsed time delta since system boot. It is not adjusted and cannot be
set.
According to the documentation, mach_timebase_info() is always equals to one mach_timebase_info() gives a fraction to convert the clock value to a number of
and does never fail, even if the function may fail according to its prototype. nanoseconds. According to the documentation (`Technical Q&A QA1398
<https://developer.apple.com/library/mac/#qa/qa1398/>`_), mach_timebase_info()
is always equals to one and does never fail, even if the function may fail
according to its prototype.
mach_absolute_time() has a resolution of 1 nanosecond. mach_absolute_time() has a resolution of 1 nanosecond.
@ -189,7 +193,7 @@ requires a kernel version 2.6.28 or later.
clock_getres() gives the clock resolution. It is 1 nanosecond on Linux. clock_getres() gives the clock resolution. It is 1 nanosecond on Linux.
.. note:: .. note::
clock_gettime() requires to link the program with the realtime ("rt") library. clock_gettime() requires to link the program to the rt (real-time) library.
QueryPerformanceCounter QueryPerformanceCounter
^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^
@ -197,7 +201,6 @@ QueryPerformanceCounter
High-resolution performance counter. It is monotonic. High-resolution performance counter. It is monotonic.
QueryPerformanceFrequency() gives its frequency. QueryPerformanceFrequency() gives its frequency.
On Windows XP, QueryPerformanceFrequency() is the processor frequency and On Windows XP, QueryPerformanceFrequency() is the processor frequency and
QueryPerformanceCounter() is the TSC of the current processor. Windows XP QueryPerformanceCounter() is the TSC of the current processor. Windows XP
had a bug (see `KB896256 <http://support.microsoft.com/?id=896256>`_): on a had a bug (see `KB896256 <http://support.microsoft.com/?id=896256>`_): on a
@ -315,9 +318,9 @@ Alternatives: API design
One function with a flag: time.monotonic(strict=False) One function with a flag: time.monotonic(strict=False)
---------------------------------------------------------- ----------------------------------------------------------
* time.monotonic(strict=False) falls back to another clock if no monotonic clock * time.monotonic(strict=False) falls back to the system clock if no monotonic
is not available or does not work, but it does never fail. clock is available or if the monotonic clock failed.
* time.monotonic(strict=True) raises OSError if monotonic clock fails or * time.monotonic(strict=True) raises OSError if monotonic clock fails and
NotImplementedError if the system does not provide a monotonic clock NotImplementedError if the system does not provide a monotonic clock
"A keyword argument that gets passed as a constant in the caller is usually "A keyword argument that gets passed as a constant in the caller is usually