summaryrefslogtreecommitdiffstats
path: root/Lib/timeit.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-10-18 15:42:48 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-10-18 15:42:48 (GMT)
commitc3e40f8c5bc7eb1c6aa60074c729219ce8881276 (patch)
tree3d3571cc555873633295107fba63f892ba1d5d85 /Lib/timeit.py
parent61de57f175bff135b85f66caa159861aa8ee18dd (diff)
downloadcpython-c3e40f8c5bc7eb1c6aa60074c729219ce8881276.zip
cpython-c3e40f8c5bc7eb1c6aa60074c729219ce8881276.tar.gz
cpython-c3e40f8c5bc7eb1c6aa60074c729219ce8881276.tar.bz2
timeit: add nsec (nanosecond) unit for format timings
Issue #28240.
Diffstat (limited to 'Lib/timeit.py')
-rw-r--r--Lib/timeit.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/timeit.py b/Lib/timeit.py
index 8bc6a9e..23bdd02 100644
--- a/Lib/timeit.py
+++ b/Lib/timeit.py
@@ -18,7 +18,7 @@ Options:
Execution time of this setup statement is NOT timed.
-p/--process: use time.process_time() (default is time.perf_counter())
-v/--verbose: print raw timing results; repeat for more digits precision
- -u/--unit: set the output time unit (usec, msec, or sec)
+ -u/--unit: set the output time unit (nsec, usec, msec, or sec)
-h/--help: print this usage message and exit
--: separate options from statement, use when statement starts with -
statement: statement to be timed (default 'pass')
@@ -272,7 +272,7 @@ def main(args=None, *, _wrap_timer=None):
repeat = default_repeat
verbose = 0
time_unit = None
- units = {"usec": 1e-6, "msec": 1e-3, "sec": 1.0}
+ units = {"nsec": 1e-9, "usec": 1e-6, "msec": 1e-3, "sec": 1.0}
precision = 3
for o, a in opts:
if o in ("-n", "--number"):
@@ -283,7 +283,7 @@ def main(args=None, *, _wrap_timer=None):
if a in units:
time_unit = a
else:
- print("Unrecognized unit. Please select usec, msec, or sec.",
+ print("Unrecognized unit. Please select nsec, usec, msec, or sec.",
file=sys.stderr)
return 2
if o in ("-r", "--repeat"):