pythonprofilercprofile

profiling a method of a class in Python using cProfile?


I'd like to profile a method of a function in Python, using cProfile. I tried the following:

import cProfile as profile

# Inside the class method...
profile.run("self.myMethod()", "output_file")

But it does not work. How can I call a self.method with "run"?


Solution

  • Use the profilehooks decorator

    http://pypi.python.org/pypi/profilehooks