PEP 418: Replace accuracy with precision
This commit is contained in:
parent
e8db274322
commit
109ea46bfa
54
pep-0418.txt
54
pep-0418.txt
|
@ -127,7 +127,7 @@ Pseudo-code [#pseudo]_::
|
|||
|
||||
|
||||
On Windows, QueryPerformanceCounter() is not used even though it has a better
|
||||
accuracy than GetTickCount(). It is not reliable and has too many issues.
|
||||
precision than GetTickCount(). It is not reliable and has too many issues.
|
||||
|
||||
.. note::
|
||||
|
||||
|
@ -242,7 +242,7 @@ Return a dictionary with the following keys:
|
|||
|
||||
* Optional keys:
|
||||
|
||||
* "accuracy" (float): accuracy in seconds of the clock
|
||||
* "precision" (float): precision in seconds of the clock
|
||||
* "is_adjusted" (bool): True if the clock can be adjusted (e.g. by a NTP
|
||||
daemon)
|
||||
|
||||
|
@ -258,12 +258,12 @@ the format used by the clock. For example, clock_gettime() uses a timespec
|
|||
structure which has two integer fields, tv_sec and tv_nsec, so the resolution
|
||||
is 1 nanosecond.
|
||||
|
||||
Accuracy
|
||||
Precision
|
||||
--------
|
||||
|
||||
The accuracy is the effective smallest difference between two timestamps of the
|
||||
The precision is the effective smallest difference between two timestamps of the
|
||||
clock. It does not reflect the stability the clock rate. For example,
|
||||
QueryPerformanceCounter() has a good accuracy but is known to not have a steady
|
||||
QueryPerformanceCounter() has a good precision but is known to not have a steady
|
||||
rate.
|
||||
|
||||
|
||||
|
@ -407,10 +407,10 @@ GetTickCount[64]() 1 ms No Yes Yes
|
|||
timeGetTime() 1 ms No Yes ?
|
||||
========================= ========== =============== ============= ===============
|
||||
|
||||
Examples of clock accuracy on x86_64:
|
||||
Examples of clock precision on x86_64:
|
||||
|
||||
========================= ================ ===============
|
||||
Name Operating system Accuracy
|
||||
Name Operating system Precision
|
||||
========================= ================ ===============
|
||||
CLOCK_MONOTONIC_RAW Linux 3.2 1 ns
|
||||
CLOCK_MONOTONIC Linux 3.2 1 ns
|
||||
|
@ -422,7 +422,7 @@ CLOCK_MONOTONIC OpenBSD 5.0 10 ms
|
|||
GetTickCount Windows Seven 15.6 ms
|
||||
========================= ================ ===============
|
||||
|
||||
For CLOCK_MONOTONIC and CLOCK_MONOTONIC_RAW, the accuracy of this table is the
|
||||
For CLOCK_MONOTONIC and CLOCK_MONOTONIC_RAW, the precision of this table is the
|
||||
result of clock_getres(). It looks like Linux does not implement
|
||||
clock_getres() and always return 1 nanosecond.
|
||||
|
||||
|
@ -507,7 +507,7 @@ Windows: QueryPerformanceCounter
|
|||
High-resolution performance counter. It is monotonic.
|
||||
QueryPerformanceFrequency() gives its frequency.
|
||||
|
||||
It has a much higher resolution, but has lower long term accuracy than
|
||||
It has a much higher resolution, but has lower long term precision than
|
||||
GetTickCount() and timeGetTime() clocks. For example, it will drift
|
||||
compared to the low precision clocks.
|
||||
|
||||
|
@ -577,8 +577,8 @@ includes time the system spends in sleep or hibernation.
|
|||
|
||||
GetTickCount64() was added to Windows Vista and Windows Server 2008.
|
||||
|
||||
The clock resolution is 1 millisecond. Its accuracy is usually around
|
||||
15 ms. It is possible to improve the accuracy using the `undocumented
|
||||
The clock resolution is 1 millisecond. Its precision is usually around
|
||||
15 ms. It is possible to improve the precision using the `undocumented
|
||||
NtSetTimerResolution() function
|
||||
<http://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/Time/NtSetTimerResolution.html>`_.
|
||||
There are applications using this undocumented function, example:
|
||||
|
@ -587,7 +587,7 @@ There are applications using this undocumented function, example:
|
|||
WaitForSingleObject() use the same timer than GetTickCount() with the same
|
||||
resolution.
|
||||
|
||||
GetTickCount() has an accuracy of 55 ms on Windows 9x.
|
||||
GetTickCount() has an precision of 55 ms on Windows 9x.
|
||||
|
||||
|
||||
Windows: timeGetTime
|
||||
|
@ -662,10 +662,10 @@ ftime() 1 ms
|
|||
time() 1 sec
|
||||
========================= ===============
|
||||
|
||||
Examples of clock accuracy on x86_64:
|
||||
Examples of clock precision on x86_64:
|
||||
|
||||
========================= ================ ===============
|
||||
Name Operating system Accuracy
|
||||
Name Operating system Precision
|
||||
========================= ================ ===============
|
||||
CLOCK_REALTIME Linux 3.2 1 ns
|
||||
CLOCK_REALTIME FreeBSD 8.2 11 ns
|
||||
|
@ -674,7 +674,7 @@ CLOCK_REALTIME OpenBSD 5.0 10 ms
|
|||
GetSystemTimeAsFileTime Windows Seven 15.6 ms
|
||||
========================= ================ ===============
|
||||
|
||||
For CLOCK_REALTIME, the accuracy of this table is the result of clock_getres().
|
||||
For CLOCK_REALTIME, the precision of this table is the result of clock_getres().
|
||||
It looks like Linux does not implement clock_getres() and always return 1
|
||||
nanosecond.
|
||||
|
||||
|
@ -691,7 +691,7 @@ The system time can be read using GetSystemTimeAsFileTime(), ftime()
|
|||
and time().
|
||||
|
||||
The system time resolution can be read using
|
||||
GetSystemTimeAdjustment(). The accuracy is usually between 1
|
||||
GetSystemTimeAdjustment(). The precision is usually between 1
|
||||
millisecond and 15 milliseconds. Resolution:
|
||||
|
||||
* GetSystemTimeAsFileTime(): 100 nanoseconds
|
||||
|
@ -723,7 +723,7 @@ clock_settime(CLOCK_REALTIME).
|
|||
Process time
|
||||
------------
|
||||
|
||||
The process time cannot be set. It It is not monotonic: the clocks stop while the
|
||||
The process time cannot be set. It is not monotonic: the clocks stop while the
|
||||
process is idle.
|
||||
|
||||
========================= ===============
|
||||
|
@ -734,10 +734,10 @@ CLOCK_PROCESS_CPUTIME_ID 1 ns
|
|||
clock() \-
|
||||
========================= ===============
|
||||
|
||||
Examples of clock accuracy on x86_64:
|
||||
Examples of clock precision on x86_64:
|
||||
|
||||
========================= ================ ===============
|
||||
Name Operating system Accuracy
|
||||
Name Operating system Precision
|
||||
========================= ================ ===============
|
||||
CLOCK_PROCESS_CPUTIME_ID Linux 3.2 1 ns
|
||||
clock() Linux 3.2 1 µs
|
||||
|
@ -747,10 +747,10 @@ clock() OpenBSD 5.0 10 ms
|
|||
GetProcessTimes() Windows Seven 15.6 ms
|
||||
========================= ================ ===============
|
||||
|
||||
The accuracy of clock() in this table is the result of 1 / CLOCKS_PER_SEC.
|
||||
For CLOCK_PROCESS_CPUTIME_ID, the accuracy of this table is the result of
|
||||
The precision of clock() in this table is the result of 1 / CLOCKS_PER_SEC.
|
||||
For CLOCK_PROCESS_CPUTIME_ID, the precision of this table is the result of
|
||||
clock_getres(). It looks like Linux does not implement clock_getres() and
|
||||
always return 1 nanosecond. For GetProcessTimes(), the accuracy is read using
|
||||
always return 1 nanosecond. For GetProcessTimes(), the precision is read using
|
||||
GetSystemTimeAdjustment().
|
||||
|
||||
|
||||
|
@ -792,19 +792,19 @@ GetThreadTimes() 100 ns
|
|||
CLOCK_THREAD_CPUTIME_ID 1 ns
|
||||
========================= ===============
|
||||
|
||||
Examples of clock accuracy on x86_64:
|
||||
Examples of clock precision on x86_64:
|
||||
|
||||
========================= ================ ===============
|
||||
Name Operating system Accuracy
|
||||
Name Operating system Precision
|
||||
========================= ================ ===============
|
||||
CLOCK_THREAD_CPUTIME_ID Linux 3.2 1 ns
|
||||
CLOCK_THREAD_CPUTIME_ID FreeBSD 8.2 1 µs
|
||||
GetThreadTimes() Windows Seven 15.6 ms
|
||||
========================= ================ ===============
|
||||
|
||||
For CLOCK_THREAD_CPUTIME_ID, the accuracy of this table is the result of
|
||||
For CLOCK_THREAD_CPUTIME_ID, the precision of this table is the result of
|
||||
clock_getres(). It looks like Linux does not implement clock_getres() and
|
||||
always return 1 nanosecond. For GetThreadTimes(), the accuracy is read using
|
||||
always return 1 nanosecond. For GetThreadTimes(), the precision is read using
|
||||
GetSystemTimeAdjustment().
|
||||
|
||||
Functions
|
||||
|
@ -1016,7 +1016,7 @@ select()
|
|||
select(nfds, readfds, writefds, exceptfs, timeout).
|
||||
|
||||
Since Linux 2.6.28, select() uses high-resolution timers to handle the timeout.
|
||||
A process has a "slack" attribute to configure the accuracy of the timeout, the
|
||||
A process has a "slack" attribute to configure the precision of the timeout, the
|
||||
default slack is 50 microseconds. Before Linux 2.6.28, timeouts for select()
|
||||
were handled by the main timing subsystem at a jiffy-level resolution. Read
|
||||
also `High- (but not too high-) resolution timeouts
|
||||
|
|
Loading…
Reference in New Issue