user1610719
user1610719

Reputation: 1303

iPython lprun not printing output

I don't know what's going on here, so thought I would ask you guys.

I just installed iPython 3.1 on Mac OSX 10.10.2

In iPython I tried my function with no results, but here is an example:

In [21]: def rn():
   ....:     for ix in range(0,100): print ix
   ....:

In [22]: %lprun rn()
0
1
2
3
4
....
98
99
Timer unit: 1e-06 s

In this type of situation I'm expecting a normal cProfile type output, showing the lines that ran and how long each one took. What am I doing wrong?

Upvotes: 3

Views: 3524

Answers (1)

Padraic Cunningham
Padraic Cunningham

Reputation: 180461

Use the -f flag to get line by line output:

%lprun -f rn  rn()

Output:

In [13]: %lprun -f rn  rn()
0
1
2
3
4
5
...
94
95
96
97
98
99
Timer unit: 1e-06 s

Total time: 0.000933 s
File: <ipython-input-4-00cddd5336b9>
Function: rn at line 1

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
     1                                           def rn():
     2       101          933      9.2    100.0        for ix in range(0,100): print ix

Upvotes: 6

Related Questions