[英]iPython %lprun on function within class
I'm wondering how to do %lprun on a python script in a class stucture. 我想知道如何在类结构中的python脚本上执行%lprun。
Say I want to see what's taking so long in run(): 说我想看看在run()中花了这么长时间:
example.py example.py
def outside_call():
mc = MLIC()
mc.run()
class MLIC(object):
def __init__():
pass
def run():
#Profile this function
Normally if run() wasn't in a class, I would use: 通常如果run()不在类中,我会使用:
%lprun -f example.run example.run()
Now I need like... 现在我需要......
%lprun -f example.MLIC.run() example.outside_call()
How do I accomplish this? 我该如何做到这一点?
I'm an idiot. 我是个白痴。
In this case, you can actually do: 在这种情况下,您实际上可以这样做:
%lprun -f example.MLIC.run() example.outside_call()
I thought I tried it but typed it wrong. 我以为我尝试了但打错了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.