[Python-checkins] peps: PEP 418: Add precision in Python of FreeBSD clocks
victor.stinner
python-checkins at python.org
Fri Apr 13 23:25:15 CEST 2012
http://hg.python.org/peps/rev/a8fc654a42c0
changeset: 4242:a8fc654a42c0
user: Victor Stinner <victor.stinner at gmail.com>
date: Fri Apr 13 23:24:44 2012 +0200
summary:
PEP 418: Add precision in Python of FreeBSD clocks
files:
pep-0418.txt | 33 +++++++++++++-----------
pep-0418/clock_precision.py | 8 +++---
2 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/pep-0418.txt b/pep-0418.txt
--- a/pep-0418.txt
+++ b/pep-0418.txt
@@ -678,8 +678,8 @@
* "slewing": change the clock frequency to be slightly faster or
slower (which is done with ``adjtime()``). Since the slew rate is
- limited to 0.5 ms/s, each second of adjustment requires an
- amortization interval of 2000 s. Thus, an adjustment of many
+ limited to 0.5 millisecond per second, each second of adjustment requires an
+ amortization interval of 2000 seconds. Thus, an adjustment of many
seconds can take hours or days to amortize.
* "stepping": jump by a large amount in a single discrete step (which
is done with ``settimeofday()``)
@@ -713,6 +713,7 @@
CLOCK_MONOTONIC 1 ns Slewed on Linux Yes No
CLOCK_MONOTONIC_RAW 1 ns No Yes No
CLOCK_BOOTTIME 1 ns ? Yes Yes
+CLOCK_UPTIME 1 ns No Yes ?
mach_absolute_time() 1 ns No Yes No
QueryPerformanceCounter() \- No Yes ?
GetTickCount[64]() 1 ms No Yes Yes
@@ -724,14 +725,15 @@
========================= ================ ========= ===================
Name Operating system Precision Precision in Python
========================= ================ ========= ===================
-CLOCK_MONOTONIC_RAW Linux 3.2 1 ns 3.0 µs
-CLOCK_MONOTONIC Linux 3.2 1 ns 1.6 µs
+CLOCK_MONOTONIC_RAW Linux 3.2 1 ns 3 µs
+CLOCK_MONOTONIC Linux 3.2 1 ns 2 µs
CLOCK_HIGHRES SunOS 5.11 2 ns ?
CLOCK_MONOTONIC SunOS 5.11 2 ns ?
QueryPerformanceCounter Windows Seven 10 ns ?
-CLOCK_MONOTONIC FreeBSD 8.2 11 ns ?
+CLOCK_UPTIME FreeBSD 8.2 11 ns 9 µs
+CLOCK_MONOTONIC FreeBSD 8.2 11 ns 7 µs
CLOCK_MONOTONIC OpenBSD 5.0 10 ms ?
-GetTickCount Windows Seven 15.6 ms ?
+GetTickCount Windows Seven 16 ms ?
========================= ================ ========= ===================
For CLOCK_xxx clocks, the precision of this table is the result of
@@ -974,11 +976,11 @@
========================= ================ ========= ===================
Name Operating system Precision Precision in Python
========================= ================ ========= ===================
-CLOCK_REALTIME Linux 3.2 1 ns 1.9 µs
-CLOCK_REALTIME FreeBSD 8.2 11 ns ?
+CLOCK_REALTIME Linux 3.2 1 ns 2 µs
+CLOCK_REALTIME FreeBSD 8.2 11 ns 7 µs
CLOCK_REALTIME SunOS 5.11 10 ms ?
CLOCK_REALTIME OpenBSD 5.0 10 ms ?
-GetSystemTimeAsFileTime Windows Seven 15.6 ms ?
+GetSystemTimeAsFileTime Windows Seven 16 ms ?
========================= ================ ========= ===================
For CLOCK_REALTIME, the precision of this table is the result of
@@ -1042,14 +1044,15 @@
========================= ================ ========= ===================
Name Operating system Precision Precision in Python
========================= ================ ========= ===================
-CLOCK_PROCESS_CPUTIME_ID Linux 3.2 1 ns 3.3 µs
+CLOCK_PROCESS_CPUTIME_ID Linux 3.2 1 ns 3 µs
clock() SunOS 5.11 1 µs ?
getrusage() Linux 3.0 4 ms 4 ms
-clock() FreeBSD 8.2 7.8 ms ?
+getrusage() FreeBSD 8.2 - 1 µs
+clock() FreeBSD 8.2 8 ms 8 ms
clock() Linux 3.2 1 µs 10 ms
times() Linux 3.0 10 ms 10 ms
clock() OpenBSD 5.0 10 ms ?
-GetProcessTimes() Windows Seven 15.6 ms ?
+GetProcessTimes() Windows Seven 16 ms ?
========================= ================ ========= ===================
The precision of clock() in this table is the result of 1 /
@@ -1102,9 +1105,9 @@
========================= ================ =============== ===================
Name Operating system Precision Precision in Python
========================= ================ =============== ===================
-CLOCK_THREAD_CPUTIME_ID Linux 3.2 1 ns ?
-CLOCK_THREAD_CPUTIME_ID FreeBSD 8.2 1 µs ?
-GetThreadTimes() Windows Seven 15.6 ms ?
+CLOCK_THREAD_CPUTIME_ID Linux 3.2 1 ns 6 µs
+CLOCK_THREAD_CPUTIME_ID FreeBSD 8.2 1 µs 1 µs
+GetThreadTimes() Windows Seven 16 ms ?
========================= ================ =============== ===================
For CLOCK_THREAD_CPUTIME_ID, the precision of this table is the result
diff --git a/pep-0418/clock_precision.py b/pep-0418/clock_precision.py
--- a/pep-0418/clock_precision.py
+++ b/pep-0418/clock_precision.py
@@ -24,11 +24,11 @@
def format_duration(dt):
if dt >= 1e-3:
- return "%.1f ms" % (dt * 1e3)
+ return "%.0f ms" % (dt * 1e3)
if dt >= 1e-6:
- return "%.1f µs" % (dt * 1e6)
+ return "%.0f µs" % (dt * 1e6)
else:
- return "%.1f ns" % (dt * 1e9)
+ return "%.0f ns" % (dt * 1e9)
def test_clock(name, func):
precision = compute_precision(func)
@@ -42,7 +42,7 @@
info = time.get_clock_info(name)
if 'precision' in info:
print("- announced precision: %s" % format_duration(info['precision']))
- print("- function: %s" % info['function'])
+ print("- implementation: %s" % info['implementation'])
print("- resolution: %s" % format_duration(info['resolution']))
clock_ids = [name for name in dir(time) if name.startswith("CLOCK_")]
--
Repository URL: http://hg.python.org/peps
More information about the Python-checkins
mailing list