我想知道如何在类结构中的 python 脚本上执行 %lprun。
假设我想看看 run() 中是什么花费了这么长时间:
例子.py
def outside_call():
mc = MLIC()
mc.run()
class MLIC(object):
def __init__():
pass
def run():
#Profile this function
通常如果 run() 不在一个类中,我会使用:
%lprun -f example.run example.run()
现在我需要...
%lprun -f example.MLIC.run() example.outside_call()
我该如何实现?
最佳答案
我是个白痴。
在这种情况下,你实际上可以这样做:
%lprun -f example.MLIC.run() example.outside_call()
我以为我试过了,但打错了。
关于python - iPython %lprun 在类中的函数上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29663899/