[Python-checkins] peps: PEP 418: Add a table with performances of TSC, ACPI PM and HPET clocks

victor.stinner python-checkins at python.org
Wed Apr 11 22:48:47 CEST 2012


http://hg.python.org/peps/rev/4387c185deb7
changeset:   4219:4387c185deb7
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Wed Apr 11 22:48:14 2012 +0200
summary:
  PEP 418: Add a table with performances of TSC, ACPI PM and HPET clocks

files:
  pep-0418.txt |  26 +++++++++++++++++++++++++-
  1 files changed, 25 insertions(+), 1 deletions(-)


diff --git a/pep-0418.txt b/pep-0418.txt
--- a/pep-0418.txt
+++ b/pep-0418.txt
@@ -299,7 +299,7 @@
   frequency. Multiple cores having different TSC values. Hibernation of system
   will reset TSC value. The RDTSC instruction can be used to read this counter.
   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.
 * Cyclone: The Cyclone timer uses a 32-bit counter on IBM Extended
   X-Architecture (EXA) chipsets which include computers that use the
@@ -310,6 +310,30 @@
 * RTC (Real-time clock). Most RTCs use a crystal oscillator with a frequency of
   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
 ==============

-- 
Repository URL: http://hg.python.org/peps


More information about the Python-checkins mailing list