iPython lprun不打印输出

use*_*719 2 python ipython

我不知道这里发生了什么,所以以为我会问你们。

我刚刚在Mac OSX 10.10.2上安装了iPython 3.1

在iPython中,我尝试了没有结果的函数,但这是一个示例:

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
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我期望输出一个正常的cProfile类型,显示运行的行以及每个行花费的时间。我究竟做错了什么?!

谢谢!

Pad*_*ham 5

使用该-f标志逐行输出:

%lprun -f rn  rn()
Run Code Online (Sandbox Code Playgroud)

输出:

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
Run Code Online (Sandbox Code Playgroud)

  • 为什么'rn rn()'?而不只是'rn()'? (3认同)