mirror of
https://github.com/python/cpython.git
synced 2025-07-14 14:55:17 +00:00
timeit: remove --clock and --time options
Issue #28240: timeit: remove -c/--clock and -t/--time command line options which were deprecated since Python 3.3.
This commit is contained in:
parent
1b90115304
commit
3d7feb9ac2
4 changed files with 5 additions and 28 deletions
|
@ -197,7 +197,7 @@ Command-Line Interface
|
||||||
|
|
||||||
When called as a program from the command line, the following form is used::
|
When called as a program from the command line, the following form is used::
|
||||||
|
|
||||||
python -m timeit [-n N] [-r N] [-u U] [-s S] [-t] [-c] [-h] [statement ...]
|
python -m timeit [-n N] [-r N] [-u U] [-s S] [-h] [statement ...]
|
||||||
|
|
||||||
Where the following options are understood:
|
Where the following options are understood:
|
||||||
|
|
||||||
|
@ -222,20 +222,12 @@ Where the following options are understood:
|
||||||
|
|
||||||
.. versionadded:: 3.3
|
.. versionadded:: 3.3
|
||||||
|
|
||||||
.. cmdoption:: -t, --time
|
|
||||||
|
|
||||||
use :func:`time.time` (deprecated)
|
|
||||||
|
|
||||||
.. cmdoption:: -u, --unit=U
|
.. cmdoption:: -u, --unit=U
|
||||||
|
|
||||||
specify a time unit for timer output; can select usec, msec, or sec
|
specify a time unit for timer output; can select usec, msec, or sec
|
||||||
|
|
||||||
.. versionadded:: 3.5
|
.. versionadded:: 3.5
|
||||||
|
|
||||||
.. cmdoption:: -c, --clock
|
|
||||||
|
|
||||||
use :func:`time.clock` (deprecated)
|
|
||||||
|
|
||||||
.. cmdoption:: -v, --verbose
|
.. cmdoption:: -v, --verbose
|
||||||
|
|
||||||
print raw timing results; repeat for more digits precision
|
print raw timing results; repeat for more digits precision
|
||||||
|
|
|
@ -293,18 +293,6 @@ class TestTimeit(unittest.TestCase):
|
||||||
# the help text, but since it's there, check for it.
|
# the help text, but since it's there, check for it.
|
||||||
self.assertEqual(s, timeit.__doc__ + ' ')
|
self.assertEqual(s, timeit.__doc__ + ' ')
|
||||||
|
|
||||||
def test_main_using_time(self):
|
|
||||||
fake_timer = FakeTimer()
|
|
||||||
s = self.run_main(switches=['-t'], timer=fake_timer)
|
|
||||||
self.assertEqual(s, self.MAIN_DEFAULT_OUTPUT)
|
|
||||||
self.assertIs(fake_timer.saved_timer, time.time)
|
|
||||||
|
|
||||||
def test_main_using_clock(self):
|
|
||||||
fake_timer = FakeTimer()
|
|
||||||
s = self.run_main(switches=['-c'], timer=fake_timer)
|
|
||||||
self.assertEqual(s, self.MAIN_DEFAULT_OUTPUT)
|
|
||||||
self.assertIs(fake_timer.saved_timer, time.clock)
|
|
||||||
|
|
||||||
def test_main_verbose(self):
|
def test_main_verbose(self):
|
||||||
s = self.run_main(switches=['-v'])
|
s = self.run_main(switches=['-v'])
|
||||||
self.assertEqual(s, dedent("""\
|
self.assertEqual(s, dedent("""\
|
||||||
|
|
|
@ -9,7 +9,7 @@ the Python Cookbook, published by O'Reilly.
|
||||||
Library usage: see the Timer class.
|
Library usage: see the Timer class.
|
||||||
|
|
||||||
Command line usage:
|
Command line usage:
|
||||||
python timeit.py [-n N] [-r N] [-s S] [-t] [-c] [-p] [-h] [--] [statement]
|
python timeit.py [-n N] [-r N] [-s S] [-p] [-h] [--] [statement]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-n/--number N: how many times to execute 'statement' (default: see below)
|
-n/--number N: how many times to execute 'statement' (default: see below)
|
||||||
|
@ -17,8 +17,6 @@ Options:
|
||||||
-s/--setup S: statement to be executed once initially (default 'pass').
|
-s/--setup S: statement to be executed once initially (default 'pass').
|
||||||
Execution time of this setup statement is NOT timed.
|
Execution time of this setup statement is NOT timed.
|
||||||
-p/--process: use time.process_time() (default is time.perf_counter())
|
-p/--process: use time.process_time() (default is time.perf_counter())
|
||||||
-t/--time: use time.time() (deprecated)
|
|
||||||
-c/--clock: use time.clock() (deprecated)
|
|
||||||
-v/--verbose: print raw timing results; repeat for more digits precision
|
-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 (usec, msec, or sec)
|
||||||
-h/--help: print this usage message and exit
|
-h/--help: print this usage message and exit
|
||||||
|
@ -291,10 +289,6 @@ def main(args=None, *, _wrap_timer=None):
|
||||||
repeat = int(a)
|
repeat = int(a)
|
||||||
if repeat <= 0:
|
if repeat <= 0:
|
||||||
repeat = 1
|
repeat = 1
|
||||||
if o in ("-t", "--time"):
|
|
||||||
timer = time.time
|
|
||||||
if o in ("-c", "--clock"):
|
|
||||||
timer = time.clock
|
|
||||||
if o in ("-p", "--process"):
|
if o in ("-p", "--process"):
|
||||||
timer = time.process_time
|
timer = time.process_time
|
||||||
if o in ("-v", "--verbose"):
|
if o in ("-v", "--verbose"):
|
||||||
|
|
|
@ -88,6 +88,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #28240: timeit: remove ``-c/--clock`` and ``-t/--time`` command line
|
||||||
|
options which were deprecated since Python 3.3.
|
||||||
|
|
||||||
- Issue #28240: timeit now repeats the benchmarks 5 times instead of only 3
|
- Issue #28240: timeit now repeats the benchmarks 5 times instead of only 3
|
||||||
to make benchmarks more reliable.
|
to make benchmarks more reliable.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue