[Python-checkins] peps: PEP 418: Fix clock_resolution.py script

victor.stinner python-checkins at python.org
Mon Sep 15 13:31:49 CEST 2014


http://hg.python.org/peps/rev/c834ee0da60d
changeset:   5552:c834ee0da60d
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Mon Sep 15 13:31:42 2014 +0200
summary:
  PEP 418: Fix clock_resolution.py script

files:
  pep-0418/clock_resolution.py |  26 +++++++++++------------
  1 files changed, 12 insertions(+), 14 deletions(-)


diff --git a/pep-0418/clock_resolution.py b/pep-0418/clock_resolution.py
--- a/pep-0418/clock_resolution.py
+++ b/pep-0418/clock_resolution.py
@@ -5,8 +5,8 @@
 except ImportError:
     from time import time as timeout_time
 
-def compute_precision(func):
-    precision = None
+def compute_resolution(func):
+    resolution = None
     points = 0
     timeout = timeout_time() + 1.0
     previous = func()
@@ -21,13 +21,13 @@
             dt = t2 - previous
             if dt <= 0.0:
                 continue
-        if precision is not None:
-            precision = min(precision, dt)
+        if resolution is not None:
+            resolution = min(resolution, dt)
         else:
-            precision = dt
+            resolution = dt
         points += 1
         previous = func()
-    return precision
+    return resolution
 
 def format_duration(dt):
     if dt >= 1e-3:
@@ -39,8 +39,8 @@
 
 def test_clock(name, func):
     print("%s:" % name)
-    precision = compute_precision(func)
-    print("- precision in Python: %s" % format_duration(precision))
+    resolution = compute_resolution(func)
+    print("- resolution in Python: %s" % format_duration(resolution))
 
 
 clocks = ['clock', 'perf_counter', 'process_time']
@@ -51,10 +51,8 @@
     func = getattr(time, name)
     test_clock("%s()" % name, func)
     info = time.get_clock_info(name)
-    if 'precision' in info:
-        print("- announced precision: %s" % format_duration(info['precision']))
-    print("- implementation: %s" % info['implementation'])
-    print("- resolution: %s" % format_duration(info['resolution']))
+    print("- implementation: %s" % info.implementation)
+    print("- resolution: %s" % format_duration(info.resolution))
 
 clock_ids = [name for name in dir(time) if name.startswith("CLOCK_")]
 clock_ids.sort()
@@ -69,6 +67,6 @@
         print("%s failed: %s" % (name, err))
         continue
     test_clock(name, gettime)
-    precision = time.clock_getres(clock_id)
-    print("- announced precision: %s" % format_duration(precision))
+    resolution = time.clock_getres(clock_id)
+    print("- announced resolution: %s" % format_duration(resolution))
 

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


More information about the Python-checkins mailing list