Skip to content
This repository

Doc magic timeit #222

Closed
wants to merge 1 commit into from

2 participants

varshinireddy Thomas Kluyver
varshinireddy

Added examples for %timeit as part of scipy India report

varshinireddy varshinireddy Wrote examples for %timeit.
Work done as a group by:
- B.Varshini
- P.Vaishnavi
- K.Santosh
- N.Venkatesh
a90f2ea
Thomas Kluyver takluyver commented on the diff
IPython/core/magic.py
@@ -1719,7 +1719,18 @@ Currently the magic system has the following functions:\n"""
1719 1719
1720 1720 In [6]: %timeit -n1 time.sleep(2)
1721 1721 1 loops, best of 3: 2 s per loop
1722   -
  1722 +
  1723 + In [7]: %timeit -n 15 x='hjsjkdhhsk'
  1724 + 15 loops, best of 3: 127 ns per loop
  1725 +
  1726 + In [8]: %timeit -n 10 -t x='hjsjkdhhsk'
  1727 + 10 loops, best of 3: 191 ns per loop
1
Thomas Kluyver Collaborator

Let's stick to 1 or 2 good examples, not half a dozen all doing pretty much the same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Thomas Kluyver
Collaborator

In fact, looking at it, we've probably got enough examples as it stands. Thanks for the help, and you're welcome to keep contributing.

Damián Avila damianavila referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Dec 18, 2010
varshinireddy varshinireddy Wrote examples for %timeit.
Work done as a group by:
- B.Varshini
- P.Vaishnavi
- K.Santosh
- N.Venkatesh
a90f2ea
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 14 additions and 3 deletions. Show diff stats Hide diff stats

  1. +14 3 IPython/core/magic.py
17 IPython/core/magic.py
@@ -1701,8 +1701,8 @@ def magic_timeit(self, parameter_s =''):
1701 1701 -p<P>: use a precision of <P> digits to display the timing result.
1702 1702 Default: 3
1703 1703
1704   -
1705   - Examples:
  1704 + Examples
  1705 + --------
1706 1706
1707 1707 In [1]: %timeit pass
1708 1708 10000000 loops, best of 3: 53.3 ns per loop
@@ -1719,7 +1719,18 @@ def magic_timeit(self, parameter_s =''):
1719 1719
1720 1720 In [6]: %timeit -n1 time.sleep(2)
1721 1721 1 loops, best of 3: 2 s per loop
1722   -
  1722 +
  1723 + In [7]: %timeit -n 15 x='hjsjkdhhsk'
  1724 + 15 loops, best of 3: 127 ns per loop
  1725 +
  1726 + In [8]: %timeit -n 10 -t x='hjsjkdhhsk'
  1727 + 10 loops, best of 3: 191 ns per loop
  1728 +
  1729 + In [9]: %timeit -n 10 -c x='hjsjkdhhsk'
  1730 + 10 loops, best of 3: 0 ns per loop
  1731 +
  1732 + In [10]: %timeit -n 10 -r 5 fun_x
  1733 + 10 loops, best of 5: 191 ns per loop
1723 1734
1724 1735 The times reported by %timeit will be slightly higher than those
1725 1736 reported by the timeit.py script when variables are accessed. This is

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.