[Python-checkins] peps: PEP 418: Rename time.highres() to time.perf_counter()
victor.stinner
python-checkins at python.org
Wed Apr 4 01:09:51 CEST 2012
http://hg.python.org/peps/rev/ebb521404664
changeset: 4196:ebb521404664
user: Victor Stinner <victor.stinner at gmail.com>
date: Wed Apr 04 01:09:35 2012 +0200
summary:
PEP 418: Rename time.highres() to time.perf_counter()
files:
pep-0418.txt | 32 +++++++++++++++++---------------
1 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/pep-0418.txt b/pep-0418.txt
--- a/pep-0418.txt
+++ b/pep-0418.txt
@@ -13,7 +13,7 @@
Abstract
========
-Add time.steady(), time.highres(), time.get_clock_info(name) functions to
+Add time.steady(), time.perf_counter(), time.get_clock_info(name) functions to
Python 3.3.
@@ -25,7 +25,7 @@
* Display the current time to a human (e.g. display a calendar or draw
a wall clock): use system clock, i.e. time.time() or
datetime.datetime.now().
-* Benchmark, profiling: time.highres().
+* Benchmark, profiling: time.perf_counter().
* Event scheduler, timeout: time.steady().
@@ -35,7 +35,7 @@
To fulfill the use cases, the functions' properties are:
* time.time(): system clock, "wall clock".
-* time.highres(): clock with the best accuracy.
+* time.perf_counter(): clock with the best accuracy.
* time.steady(): steady clock, should be monotonic
* time.get_clock_info(name): get information on the specified time function
@@ -165,8 +165,8 @@
different in two Python processes.
-time.highres()
---------------
+time.perf_counter()
+-------------------
Clock with the best available resolution.
@@ -174,24 +174,24 @@
Pseudo-code::
- def highres():
- if highres.use_performance_counter:
+ def perf_counter():
+ if perf_counter.use_performance_counter:
try:
return _time.QueryPerformanceCounter()
except OSError:
# QueryPerformanceFrequency() may fail, if the installed
# hardware does not support a high-resolution performance
# counter for example
- highres.use_performance_counter = False
- if highres.use_steady:
+ perf_counter.use_performance_counter = False
+ if perf_counter.use_steady:
# Monotonic clock is preferred over system clock
try:
return time.steady()
except OSError:
- highres.use_steady = False
+ perf_counter.use_steady = False
return time.time()
- highres.use_performance_counter = (os.name == 'nt')
- highres.use_steady = hasattr(time, 'steady')
+ perf_counter.use_performance_counter = (os.name == 'nt')
+ perf_counter.use_steady = hasattr(time, 'steady')
time.get_clock_info(name)
-------------------------
@@ -199,7 +199,7 @@
Get information on the specified clock. Supported clocks:
* "clock": time.clock()
- * "highres": time.highres()
+ * "perf_counter": time.perf_counter()
* "steady": time.steady()
* "time": time.time()
@@ -794,8 +794,9 @@
Other names for new functions
-----------------------------
-time.highres():
+time.perf_counter():
+* time.highres()
* time.hires(): "hires" can be read as "to hire" as in "he hires a car
to go on holiday", rather than a "HIgh-RESolution clock".
* time.timer(): "it would be too easy to confuse with (or misspell as)
@@ -827,8 +828,8 @@
time.monotonic() is always a monotonic clock and is only available if the
operating system provides a monotonic clock.
-time.highres() is only available if the operating system provides a clock with
-a high resolution (e.g. at least a microsecond or better).
+time.perf_counter() is only available if the operating system provides a clock
+with a high resolution (e.g. at least a microsecond or better).
One function choosing the clock from a list of constrains
--
Repository URL: http://hg.python.org/peps
More information about the Python-checkins
mailing list