Would it be possible to show the class name in the results ?
Hello,
First many thanks for the work you put in this tool, it was the one i was dreaming of.
I'm using it to find bottlenecks in Django applications.
In this case i got multiple classes having a method called get_total(), would it be possible to display the class name to differentiate the different get_total() functions like Invoice.get_total(), InvoiceLine.get_total() or InvoiceQuerySet.get_total() in the results instead of just get_total. It would be more convenient than having to check which is which in the source file during the reading.
Regards,
Alti.
Yes, this would be really nice. It's not something that is naturally available via the native Python frame interface but I think it's possible to 'guess' by looking at the type of an argument called self in the scope of the function. We'd have to be a little careful not to make it too slow, but I think there should be a way.
If you or somebody else is interested in working on a PR, the place to try adding it would be https://github.com/joerick/pyinstrument/blob/master/pyinstrument/profiler.py#L93, adding it to the first token in the identifier :)
Hi there,
Reference from the above comment is outdated, as code has changed over time, this one has commit hash: https://github.com/joerick/pyinstrument/blob/568f2b78fb34e455420d3da5925c5f51734b0c79/pyinstrument/profiler.py#L93-L95
I created PR #154 that might be a possible solution.
@joerick thanks again for the great instrument!
This now works in v4.4.0!