PEP 418: Mention the Technical Q&A QA1398 for mach_absolute_time()
This commit is contained in:
parent
02b9a5bcb3
commit
aaa1107673
23
pep-0418.txt
23
pep-0418.txt
|
@ -137,7 +137,7 @@ system time.
|
|||
|
||||
It is available on all platforms and cannot fail.
|
||||
|
||||
Pseudo-code [#pseudo]_: ::
|
||||
Pseudo-code::
|
||||
|
||||
def hires():
|
||||
if hires.use_monotonic:
|
||||
|
@ -158,11 +158,15 @@ Monotonic
|
|||
mach_absolute_time
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Mac OS X provides a monotonic clock: mach_absolute_time(). mach_timebase_info()
|
||||
provides a fraction to convert the clock value to a number of nanoseconds.
|
||||
Mac OS X provides a monotonic clock: mach_absolute_time(). It is based on
|
||||
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
|
||||
and does never fail, even if the function may fail according to its prototype.
|
||||
mach_timebase_info() gives a fraction to convert the clock value to a number of
|
||||
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.
|
||||
|
||||
|
@ -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.
|
||||
|
||||
.. 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
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -197,7 +201,6 @@ QueryPerformanceCounter
|
|||
High-resolution performance counter. It is monotonic.
|
||||
QueryPerformanceFrequency() gives its frequency.
|
||||
|
||||
|
||||
On Windows XP, QueryPerformanceFrequency() is the processor frequency and
|
||||
QueryPerformanceCounter() is the TSC of the current processor. Windows XP
|
||||
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)
|
||||
----------------------------------------------------------
|
||||
|
||||
* time.monotonic(strict=False) falls back to another clock if no monotonic clock
|
||||
is not available or does not work, but it does never fail.
|
||||
* time.monotonic(strict=True) raises OSError if monotonic clock fails or
|
||||
* time.monotonic(strict=False) falls back to the system clock if no monotonic
|
||||
clock is available or if the monotonic clock failed.
|
||||
* time.monotonic(strict=True) raises OSError if monotonic clock fails and
|
||||
NotImplementedError if the system does not provide a monotonic clock
|
||||
|
||||
"A keyword argument that gets passed as a constant in the caller is usually
|
||||
|
|
Loading…
Reference in New Issue