iPython %lprun on function within class

2019-05-26 02:57发布

I'm wondering how to do %lprun on a python script in a class stucture.

Say I want to see what's taking so long in run():

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:

%lprun -f example.run example.run()

Now I need like...

%lprun -f example.MLIC.run() example.outside_call()

How do I accomplish this?

1条回答
何必那么认真
2楼-- · 2019-05-26 03:39

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.

查看更多
登录 后发表回答