python - iPython %lprun 在类中的函数上

标签 python ipython

我想知道如何在类结构中的 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/

相关文章:

python - 用 Python 自动化无聊的事情 - Collat​​z Sequence

python - IPython Notebook session 中的多个目录和/或子目录?

python - 如何获取kivy中小部件的位置

Python 对象属性是另一个对象,不会使用 pickle.load() 加载。我究竟做错了什么?

python - RabbitMQ:Pika:消费时添加超时

python - 如何在 Python 3.5 中使用 async/await?

python - 在 AWS EMR v4.0.0 上使用 Pyspark 配置 Ipython/Jupyter notebook

python - 在IPython中运行ProcessPoolExecutor

macos - OS X - 谁能解释为什么我在安装 ipython3 后在我的 .pythonrc.py 文件中收到操作系统错误,或者给我一个比这更强大的解决方案?

python - 如何检查 iPython 中对象的内存使用情况?