PEP 418: Add a table with performances of TSC, ACPI PM and HPET clocks

This commit is contained in:
Victor Stinner 2012-04-11 22:48:14 +02:00
parent 552c8c82ec
commit a7be2f184d
1 changed files with 25 additions and 1 deletions

View File

@ -299,7 +299,7 @@ Hardware clocks
frequency. Multiple cores having different TSC values. Hibernation of system frequency. Multiple cores having different TSC values. Hibernation of system
will reset TSC value. The RDTSC instruction can be used to read this counter. will reset TSC value. The RDTSC instruction can be used to read this counter.
CPU frequency scaling for power saving. CPU frequency scaling for power saving.
* ACPI PMTMR (power management timer): ACPI 24-bit timer with a frequency * ACPI PMTMR (Power Management TiMeR): ACPI 24-bit timer with a frequency
of 3.5 MHz (3,579,545 Hz). HPET can cause around 3 seconds of drift per day. of 3.5 MHz (3,579,545 Hz). HPET can cause around 3 seconds of drift per day.
* Cyclone: The Cyclone timer uses a 32-bit counter on IBM Extended * Cyclone: The Cyclone timer uses a 32-bit counter on IBM Extended
X-Architecture (EXA) chipsets which include computers that use the X-Architecture (EXA) chipsets which include computers that use the
@ -310,6 +310,30 @@ Hardware clocks
* RTC (Real-time clock). Most RTCs use a crystal oscillator with a frequency of * RTC (Real-time clock). Most RTCs use a crystal oscillator with a frequency of
32,768 Hz 32,768 Hz
Reading an hardware clock has a cost. The following table compares the
performance of different hardware clocks on Linux 3.3 with Intel Core i7-2600
at 3.40GHz (8 cores).
======================== ====== ======= ======
Function TSC ACPI PM HPET
======================== ====== ======= ======
time() 2 ns 2 ns 2 ns
CLOCK_REALTIME_COARSE 10 ns 10 ns 10 ns
CLOCK_MONOTONIC_COARSE 12 ns 13 ns 12 ns
CLOCK_THREAD_CPUTIME_ID 134 ns 135 ns 135 ns
CLOCK_PROCESS_CPUTIME_ID 127 ns 129 ns 129 ns
clock() 146 ns 146 ns 143 ns
gettimeofday() 23 ns 726 ns 637 ns
CLOCK_MONOTONIC_RAW 31 ns 716 ns 607 ns
CLOCK_REALTIME 27 ns 707 ns 629 ns
CLOCK_MONOTONIC 27 ns 723 ns 635 ns
======================== ====== ======= ======
Each function was called 10,000,000 times and CLOCK_MONOTONIC was used to get
the time before and after. The benchmark was run 5 times to keep the minimum
time.
NTP adjustment NTP adjustment
============== ==============