Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
aea83f53
Commit
aea83f53
authored
Sep 20, 2012
by
Ezio Melotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix rst markup in timeit docs.
parent
6d6fb3aa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
Doc/library/timeit.rst
Doc/library/timeit.rst
+15
-15
No files found.
Doc/library/timeit.rst
View file @
aea83f53
...
@@ -23,7 +23,7 @@ for measuring execution times. See also Tim Peters' introduction to the
...
@@ -23,7 +23,7 @@ for measuring execution times. See also Tim Peters' introduction to the
The module defines the following public class:
The module defines the following public class:
.. class:: Timer(
[stmt='pass' [, setup='pass' [, timer=<timer function>]]]
)
.. class:: Timer(
stmt='pass', setup='pass', timer=<timer function>
)
Class for timing execution speed of small code snippets.
Class for timing execution speed of small code snippets.
...
@@ -33,18 +33,18 @@ The module defines the following public class:
...
@@ -33,18 +33,18 @@ The module defines the following public class:
may also contain multiple statements separated by ``;`` or newlines, as long as
may also contain multiple statements separated by ``;`` or newlines, as long as
they don't contain multi-line string literals.
they don't contain multi-line string literals.
To measure the execution time of the first statement, use the :meth:`timeit`
To measure the execution time of the first statement, use the :meth:`
Timer.
timeit`
method. The :meth:`repeat` method is a convenience to call :meth:`timeit`
method. The :meth:`repeat` method is a convenience to call :meth:`
.
timeit`
multiple times and return a list of results.
multiple times and return a list of results.
.. versionchanged:: 2.6
.. versionchanged:: 2.6
The *stmt* and *setup* parameters can now also take objects that are callable
The *stmt* and *setup* parameters can now also take objects that are callable
without arguments. This will embed calls to them in a timer function that will
without arguments. This will embed calls to them in a timer function that will
then be executed by :meth:`
timeit`. Note that the timing overhead is a little
then be executed by :meth:`
.timeit`. Note that the timing overhead is a
larger in this case because of the extra function calls.
l
ittle l
arger in this case because of the extra function calls.
.. method:: Timer.print_exc(
[file=None]
)
.. method:: Timer.print_exc(
file=None
)
Helper to print a traceback from the timed code.
Helper to print a traceback from the timed code.
...
@@ -61,14 +61,14 @@ The module defines the following public class:
...
@@ -61,14 +61,14 @@ The module defines the following public class:
traceback is sent; it defaults to ``sys.stderr``.
traceback is sent; it defaults to ``sys.stderr``.
.. method:: Timer.repeat(
[repeat=3 [, number=1000000]]
)
.. method:: Timer.repeat(
repeat=3, number=1000000
)
Call :meth:`timeit` a few times.
Call :meth:`
.
timeit` a few times.
This is a convenience function that calls the :meth:`timeit` repeatedly,
This is a convenience function that calls the :meth:`
.
timeit` repeatedly,
returning a list of results. The first argument specifies how many times to
returning a list of results. The first argument specifies how many times to
call :meth:`timeit`. The second argument specifies the *number* argument for
call :meth:`
.
timeit`. The second argument specifies the *number* argument for
:
func:`
timeit`.
:
meth:`.
timeit`.
.. note::
.. note::
...
@@ -82,7 +82,7 @@ The module defines the following public class:
...
@@ -82,7 +82,7 @@ The module defines the following public class:
and apply common sense rather than statistics.
and apply common sense rather than statistics.
.. method:: Timer.timeit(
[number=1000000]
)
.. method:: Timer.timeit(
number=1000000
)
Time *number* executions of the main statement. This executes the setup
Time *number* executions of the main statement. This executes the setup
statement once, and then returns the time it takes to execute the main statement
statement once, and then returns the time it takes to execute the main statement
...
@@ -92,7 +92,7 @@ The module defines the following public class:
...
@@ -92,7 +92,7 @@ The module defines the following public class:
.. note::
.. note::
By default, :meth:`timeit` temporarily turns off :term:`garbage collection`
By default, :meth:`
.
timeit` temporarily turns off :term:`garbage collection`
during the timing. The advantage of this approach is that it makes
during the timing. The advantage of this approach is that it makes
independent timings more comparable. This disadvantage is that GC may be
independent timings more comparable. This disadvantage is that GC may be
an important component of the performance of the function being measured.
an important component of the performance of the function being measured.
...
@@ -126,7 +126,7 @@ The module also defines three convenience functions:
...
@@ -126,7 +126,7 @@ The module also defines three convenience functions:
.. function:: timeit(stmt, setup='pass', timer=default_timer, number=1000000)
.. function:: timeit(stmt, setup='pass', timer=default_timer, number=1000000)
Create a :class:`Timer` instance with the given statement, setup code and timer
Create a :class:`Timer` instance with the given statement, setup code and timer
function and run its :meth:`timeit` method with *number* executions.
function and run its :meth:`
.
timeit` method with *number* executions.
.. versionadded:: 2.6
.. versionadded:: 2.6
...
@@ -248,7 +248,7 @@ attributes. ::
...
@@ -248,7 +248,7 @@ attributes. ::
3.15 usec/pass
3.15 usec/pass
To give the :mod:`timeit` module access to functions you define, you can pass a
To give the :mod:`timeit` module access to functions you define, you can pass a
``setup``
parameter which contains an import statement::
*setup*
parameter which contains an import statement::
def test():
def test():
"""Stupid test function"""
"""Stupid test function"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment