summaryrefslogtreecommitdiffstats
path: root/Doc/library/timeit.rst
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2011-08-06 05:37:04 (GMT)
committerSenthil Kumaran <senthil@uthcode.com>2011-08-06 05:37:04 (GMT)
commit2e0153550cc33b94b7cc94650ae9543ffd58637c (patch)
treed2074eda3567dfed34c0d1716ac4029d38d2d01c /Doc/library/timeit.rst
parenta3b2316a1b858c889dcaeddc4c4ec890b42ddf5a (diff)
downloadcpython-2e0153550cc33b94b7cc94650ae9543ffd58637c.zip
cpython-2e0153550cc33b94b7cc94650ae9543ffd58637c.tar.gz
cpython-2e0153550cc33b94b7cc94650ae9543ffd58637c.tar.bz2
Fix closes Issue12697 - Update the usage syntax of timeit module in the docs.
Diffstat (limited to 'Doc/library/timeit.rst')
-rw-r--r--Doc/library/timeit.rst12
1 files changed, 6 insertions, 6 deletions
diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst
index a03e40e..0112994 100644
--- a/Doc/library/timeit.rst
+++ b/Doc/library/timeit.rst
@@ -191,13 +191,13 @@ interface) that compare the cost of using :func:`hasattr` vs.
:keyword:`try`/:keyword:`except` to test for missing and present object
attributes. ::
- % timeit.py 'try:' ' str.__bool__' 'except AttributeError:' ' pass'
+ $ python -m timeit 'try:' ' str.__bool__' 'except AttributeError:' ' pass'
100000 loops, best of 3: 15.7 usec per loop
- % timeit.py 'if hasattr(str, "__bool__"): pass'
+ $ python -m timeit 'if hasattr(str, "__bool__"): pass'
100000 loops, best of 3: 4.26 usec per loop
- % timeit.py 'try:' ' int.__bool__' 'except AttributeError:' ' pass'
+ $ python -m timeit 'try:' ' int.__bool__' 'except AttributeError:' ' pass'
1000000 loops, best of 3: 1.43 usec per loop
- % timeit.py 'if hasattr(int, "__bool__"): pass'
+ $ python -m timeit 'if hasattr(int, "__bool__"): pass'
100000 loops, best of 3: 2.23 usec per loop
::
@@ -238,10 +238,10 @@ To give the :mod:`timeit` module access to functions you define, you can pass a
``setup`` parameter which contains an import statement::
def test():
- "Stupid test function"
+ """Stupid test function"""
L = [i for i in range(100)]
- if __name__=='__main__':
+ if __name__ == '__main__':
from timeit import Timer
t = Timer("test()", "from __main__ import test")
print(t.timeit())