pyinstrument icon indicating copy to clipboard operation
pyinstrument copied to clipboard

Include percentages of parent in the report

Open asmeurer opened this issue 3 years ago • 2 comments

It would be useful if the report showed the percentage of the time spent relative to the other frames with the same parent in addition to the absolute time.

I looked at the code, and the frame objects do not seem to reference their parents, only their children, so this isn't so easy to add as a simple method on the frame object without introducing the circular reference (not sure if that's OK to do).

asmeurer avatar Jun 09 '21 19:06 asmeurer

Hi @asmeurer ! I'm not sure how we'd incorporate visually into the output, but it should be easy enough to write a renderer to do it - the Frame objects do reference their parent and there's already a property : https://github.com/joerick/pyinstrument/blob/master/pyinstrument/frame.py#L21 that gives a number between 0 and 1 indicating the fraction of parent time.

joerick avatar Jun 16 '21 11:06 joerick

Percentage time was added in v4.3.0, although this is relative to the total, not the parent.

joerick avatar Nov 05 '22 12:11 joerick