From 707a52a156851c7d8f6ebaedb6c98ef52a756186 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 18 Oct 2016 17:18:21 +0200 Subject: 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. --- Doc/library/timeit.rst | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'Doc/library/timeit.rst') diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst index 5bae33bc8f..bad7194f09 100644 --- a/Doc/library/timeit.rst +++ b/Doc/library/timeit.rst @@ -197,7 +197,7 @@ Command-Line Interface 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: @@ -222,20 +222,12 @@ Where the following options are understood: .. versionadded:: 3.3 -.. cmdoption:: -t, --time - - use :func:`time.time` (deprecated) - .. cmdoption:: -u, --unit=U specify a time unit for timer output; can select usec, msec, or sec .. versionadded:: 3.5 -.. cmdoption:: -c, --clock - - use :func:`time.clock` (deprecated) - .. cmdoption:: -v, --verbose print raw timing results; repeat for more digits precision -- cgit v1.2.1 From 29560e62d585e46739ddf27f630337b1f5dc8198 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 18 Oct 2016 17:42:48 +0200 Subject: timeit: add nsec (nanosecond) unit for format timings Issue #28240. --- Doc/library/timeit.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Doc/library/timeit.rst') diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst index bad7194f09..5cb174c21b 100644 --- a/Doc/library/timeit.rst +++ b/Doc/library/timeit.rst @@ -224,7 +224,7 @@ Where the following options are understood: .. 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 nsec, usec, msec, or sec .. versionadded:: 3.5 -- cgit v1.2.1 From f1796723da117f8ffff0882333777e26fc0acb53 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 23 Oct 2016 15:17:05 +0300 Subject: Issue #28469: timeit now uses the sequence 1, 2, 5, 10, 20, 50,... instead of 1, 10, 100,... for autoranging. --- Doc/library/timeit.rst | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'Doc/library/timeit.rst') diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst index d4ddd646d8..4065808854 100644 --- a/Doc/library/timeit.rst +++ b/Doc/library/timeit.rst @@ -28,11 +28,11 @@ can be used to compare three different expressions: .. code-block:: sh $ python3 -m timeit '"-".join(str(n) for n in range(100))' - 10000 loops, best of 3: 30.2 usec per loop + 10000 loops, best of 5: 30.2 usec per loop $ python3 -m timeit '"-".join([str(n) for n in range(100)])' - 10000 loops, best of 3: 27.5 usec per loop + 10000 loops, best of 5: 27.5 usec per loop $ python3 -m timeit '"-".join(map(str, range(100)))' - 10000 loops, best of 3: 23.2 usec per loop + 10000 loops, best of 5: 23.2 usec per loop This can be achieved from the :ref:`python-interface` with:: @@ -141,9 +141,8 @@ The module defines three convenience functions and a public class: This is a convenience function that calls :meth:`.timeit` repeatedly so that the total time >= 0.2 second, returning the eventual (number of loops, time taken for that number of loops). It calls - :meth:`.timeit` with *number* set to successive powers of ten (10, - 100, 1000, ...) up to a maximum of one billion, until the time taken - is at least 0.2 second, or the maximum is reached. + :meth:`.timeit` with increasing numbers from the sequence 1, 2, 5, + 10, 20, 50, ... until the time taken is at least 0.2 second. If *callback* is given and is not ``None``, it will be called after each trial with two arguments: ``callback(number, time_taken)``. @@ -268,9 +267,9 @@ It is possible to provide a setup statement that is executed only once at the be .. code-block:: sh $ python -m timeit -s 'text = "sample string"; char = "g"' 'char in text' - 10000000 loops, best of 3: 0.0877 usec per loop + 5000000 loops, best of 5: 0.0877 usec per loop $ python -m timeit -s 'text = "sample string"; char = "g"' 'text.find(char)' - 1000000 loops, best of 3: 0.342 usec per loop + 1000000 loops, best of 5: 0.342 usec per loop :: @@ -297,14 +296,14 @@ to test for missing and present object attributes: .. code-block:: sh $ python -m timeit 'try:' ' str.__bool__' 'except AttributeError:' ' pass' - 100000 loops, best of 3: 15.7 usec per loop + 20000 loops, best of 5: 15.7 usec per loop $ python -m timeit 'if hasattr(str, "__bool__"): pass' - 100000 loops, best of 3: 4.26 usec per loop + 50000 loops, best of 5: 4.26 usec per loop $ python -m timeit 'try:' ' int.__bool__' 'except AttributeError:' ' pass' - 1000000 loops, best of 3: 1.43 usec per loop + 200000 loops, best of 5: 1.43 usec per loop $ python -m timeit 'if hasattr(int, "__bool__"): pass' - 100000 loops, best of 3: 2.23 usec per loop + 100000 loops, best of 5: 2.23 usec per loop :: -- cgit v1.2.1