From 58bb56489de0a24e2a9af72a4c42e9ee0c57c805 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sat, 14 Apr 2012 02:08:16 +0200 Subject: [PATCH] PEP 418: Fill "Include suspend" column of all tables --- pep-0418.txt | 90 ++++++++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 41 deletions(-) diff --git a/pep-0418.txt b/pep-0418.txt index 5045a63f7..3c38ac025 100644 --- a/pep-0418.txt +++ b/pep-0418.txt @@ -160,14 +160,11 @@ On Windows, ``QueryPerformanceCounter()`` is not used even though it has a better precision than ``GetTickCount()``. It is not reliable and has too many issues. -.. note:: - - ``time.monotonic()`` detects ``GetTickCount()`` integer overflow - (32 bits, roll-over after 49.7 days): it increases a delta by 2\ - :sup:`32` each time than an overflow is detected. The delta is - stored in the process-local state and so the value of - ``time.monotonic()`` may be different in two Python processes - running for more than 49 days. +``time.monotonic()`` detects ``GetTickCount()`` integer overflow (32 bits, +roll-over after 49.7 days): it increases a delta by 2\ :sup:`32` each time +than an overflow is detected. The delta is stored in the process-local +state and so the value of ``time.monotonic()`` may be different in two +Python processes running for more than 49 days. time.perf_counter() @@ -391,7 +388,8 @@ Glossary :Accuracy: Is the answer correct? Any clock will eventually ; if a clock is intended to match , it will need to be - back to the "true" time. + back to the "true" time. See also `Accuracy and precision + `_. :Adjusted: Resetting a clock to the correct time. This may be done either @@ -709,7 +707,7 @@ Monotonic clocks Name Resolution Adjusted Include sleep Include suspend ========================= ========== =============== ============= =============== gethrtime() 1 ns No Yes Yes -CLOCK_HIGHRES 1 ns No Yes ? +CLOCK_HIGHRES 1 ns No Yes Yes CLOCK_MONOTONIC 1 ns Slewed on Linux Yes No CLOCK_MONOTONIC_COARSE 1 ns Slewed on Linux Yes No CLOCK_MONOTONIC_RAW 1 ns No Yes No @@ -807,10 +805,6 @@ similar to CLOCK_MONOTONIC, less precise but faster. clock, even if the standard C library supports it. For example, CLOCK_MONOTONIC_RAW requires a kernel version 2.6.28 or later. -.. note:: - - ``clock_gettime()`` requires to link the program against the rt - (real-time) library. Windows: QueryPerformanceCounter ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -963,16 +957,16 @@ On Solaris, gethrtime() is the same as clock_gettime(CLOCK_MONOTONIC). System time clocks ------------------ -========================= =============== ============= -Name Resolution Include sleep -========================= =============== ============= -CLOCK_REALTIME 1 ns Yes -CLOCK_REALTIME_COARSE 1 ns Yes -GetSystemTimeAsFileTime 100 ns Yes -gettimeofday() 1 µs Yes -ftime() 1 ms Yes -time() 1 sec Yes -========================= =============== ============= +========================= =============== ============= =============== +Name Resolution Include sleep Include suspend +========================= =============== ============= =============== +CLOCK_REALTIME 1 ns Yes Yes +CLOCK_REALTIME_COARSE 1 ns Yes Yes +GetSystemTimeAsFileTime 100 ns Yes Yes +gettimeofday() 1 µs Yes Yes +ftime() 1 ms Yes Yes +time() 1 sec Yes Yes +========================= =============== ============= =============== Examples of clock precision on x86_64: @@ -1025,15 +1019,15 @@ Process time The process time cannot be set. It is not monotonic: the clocks stop while the process is idle. -========================= ========== ============= -Name Resolution Include sleep -========================= ========== ============= -GetProcessTimes() 100 ns No -CLOCK_PROCESS_CPUTIME_ID 1 ns No -getrusage(RUSAGE_SELF) 1 µs No -times() \- No -clock() \- No (*) -========================= ========== ============= +========================= ========== ============= =============== +Name Resolution Include sleep Include suspend +========================= ========== ============= =============== +GetProcessTimes() 100 ns No No +CLOCK_PROCESS_CPUTIME_ID 1 ns No No +getrusage(RUSAGE_SELF) 1 µs No No +times() \- No No +clock() \- No (*) No +========================= ========== ============= =============== (*) On Windows, clock() does include time elapsed during a sleep. It does not on other operating systems. @@ -1081,6 +1075,10 @@ Python source code includes a portable library to get the process time (CPU time): `Tools/pybench/systimes.py `_. +See also the `QueryProcessCycleTime() function +`_ +(sum of the cycle time of all threads). + Thread time ----------- @@ -1088,12 +1086,12 @@ Thread time The thread time cannot be set. It is not monotonic: the clocks stop while the thread is idle. -========================= ========== -Name Resolution -========================= ========== -CLOCK_THREAD_CPUTIME_ID 1 ns -GetThreadTimes() 100 ns -========================= ========== +========================= ========== ============= =============== +Name Resolution Include sleep Include suspend +========================= ========== ============= =============== +CLOCK_THREAD_CPUTIME_ID 1 ns Yes Epoch changes +GetThreadTimes() 100 ns No ? +========================= ========== ============= =============== Examples of clock precision on x86_64: @@ -1105,16 +1103,22 @@ CLOCK_THREAD_CPUTIME_ID Linux 3.2 1 ns 6 GetThreadTimes() Windows Seven 16 ms 16 ms ========================= ================ =============== =================== +CLOCK_THREAD_CPUTIME_ID returns a number of CPU cycles, not a number of +seconds. + Functions ^^^^^^^^^ * Windows: GetThreadTimes(). The precision can be read using - GetSystemTimeAdjustment(). + GetSystemTimeAdjustment(). `MSDN documentation of GetThreadTimes() + `_. * clock_gettime(CLOCK_THREAD_CPUTIME_ID): Thread-specific CPU-time clock. The precision can be read using of clock_getres(). -See also pthread_getcpuclockid(). +See also the `QueryThreadCycleTime() function +`_ +(cycle time for the specified thread) and pthread_getcpuclockid(). Windows: QueryUnbiasedInterruptTime @@ -1130,6 +1134,10 @@ QueryUnbiasedInterruptTime() is not monotonic. QueryUnbiasedInterruptTime() was introduced in Windows 7. +See also `QueryIdleProcessorCycleTime() function +`_ +(cycle time for the idle thread of each processor) + Sleep, suspend and monotonic time =================================