Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Doc magic timeit #222

Closed
wants to merge 1 commit into from

2 participants

@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
@takluyver takluyver commented on the diff
IPython/core/magic.py
@@ -1719,7 +1719,18 @@ Currently the magic system has the following functions:\n"""
In [6]: %timeit -n1 time.sleep(2)
1 loops, best of 3: 2 s per loop
-
+
+ In [7]: %timeit -n 15 x='hjsjkdhhsk'
+ 15 loops, best of 3: 127 ns per loop
+
+ In [8]: %timeit -n 10 -t x='hjsjkdhhsk'
+ 10 loops, best of 3: 191 ns per loop
@takluyver Owner

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
@takluyver
Owner

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.

@damianavila 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
Commits on Dec 18, 2010
  1. @varshinireddy

    Wrote examples for %timeit.

    varshinireddy authored
    Work done as a group by:
    - B.Varshini
    - P.Vaishnavi
    - K.Santosh
    - N.Venkatesh
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 3 deletions.
  1. +14 −3 IPython/core/magic.py
View
17 IPython/core/magic.py
@@ -1701,8 +1701,8 @@ def magic_timeit(self, parameter_s =''):
-p<P>: use a precision of <P> digits to display the timing result.
Default: 3
-
- Examples:
+ Examples
+ --------
In [1]: %timeit pass
10000000 loops, best of 3: 53.3 ns per loop
@@ -1719,7 +1719,18 @@ def magic_timeit(self, parameter_s =''):
In [6]: %timeit -n1 time.sleep(2)
1 loops, best of 3: 2 s per loop
-
+
+ In [7]: %timeit -n 15 x='hjsjkdhhsk'
+ 15 loops, best of 3: 127 ns per loop
+
+ In [8]: %timeit -n 10 -t x='hjsjkdhhsk'
+ 10 loops, best of 3: 191 ns per loop
@takluyver Owner

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
+
+ In [9]: %timeit -n 10 -c x='hjsjkdhhsk'
+ 10 loops, best of 3: 0 ns per loop
+
+ In [10]: %timeit -n 10 -r 5 fun_x
+ 10 loops, best of 5: 191 ns per loop
The times reported by %timeit will be slightly higher than those
reported by the timeit.py script when variables are accessed. This is
Something went wrong with that request. Please try again.