line_profiler 不返回任何输出

jbz*_*kid 5 python macos profiling

我已经line_profiler使用安装了pip install line_profiler。我使用的是 Mac OSX 10.8.5,带有 Python 2.7。

我跑kernprof -l ~/Desktop/sum.py,然后得到

(default code output)
Wrote profile results to sum.py.lprof
Run Code Online (Sandbox Code Playgroud)

但跑步python -m line_profiler sum.py.lprof给了我:

Timer unit: 1e-06 s
Run Code Online (Sandbox Code Playgroud)

并且没有其他输出。我的程序代码在这里:sum.py

jbz*_*kid 3

jonrsharpe 的评论是正确的,我忘记在函数头之前添加@profile。