Permalink
Browse files

Wrote examples for %timeit.

Work done as a group by:
- B.Varshini
- P.Vaishnavi
- K.Santosh
- N.Venkatesh
  • Loading branch information...
1 parent 3498382 commit a90f2ea11536943fb817b82fee014bafd804da63 @varshinireddy committed Dec 18, 2010
Showing with 14 additions and 3 deletions.
  1. +14 −3 IPython/core/magic.py
View
@@ -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
+
+ 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

0 comments on commit a90f2ea

Please sign in to comment.