I have some existing code that I'm trying to profile. I can successfully line profile class methods by adding a @profile decorator, and using kernprof.
Is there a general way to profile class instantiation? I have a few classes that have a quite complex inheritance structure. When I try to profile their init functions I get something like this:
Line # Hits Time Per Hit % Time Line Contents
==============================================================
179 def __init__(self, data):
180 1 8910739.0 8910739.0 100.0 super().__init__(data)
181 1 10.0 10.0 0.0 self.mortgage_rate = 5.2 # rate in percentage
Which is a bit useless, because I don't know what actual parent init function (this class has 2 parents, each of which have one or more parents) is being called.
Is there way way to do this better? For example, is there a way to automatically dive into each line, and profile the lines that get called by it (with limited depth?)
from Line profiling class instantiation in python
No comments:
Post a Comment