pyinstrument icon indicating copy to clipboard operation
pyinstrument copied to clipboard

Proposal: Optionally Skip Frames in Output

Open mlucool opened this issue 3 years ago • 5 comments
trafficstars

Hi,

__tracebackhide__ is used in pytest and IPython to tell tooling that a frame should be hidden from the user when looking at stacktraces. It would be helpful if users can optionally reuse this marking to tell pyinstrument not to show it in output. This is generally helpful as it enables you focus on user code you can control instead of library code that you cannot.

Example:

0.100 A
    |- 0.090 B
         |- 0.080 C
               | - 0.070 D

If B and C are hidden, we'd show:

0.100 A
   |- <skipped 2 frames>
       |- 0.070 D

mlucool avatar May 18 '22 18:05 mlucool

Interesting. So if this local is set tooling should ignore these frames? It will require some refactorings and might have a perf impact but looks like a good idea!

joerick avatar May 18 '22 19:05 joerick

Exactly!

mlucool avatar May 18 '22 20:05 mlucool

Is this something you want to tackle or would you prefer someone makes a PR with this feature for you to review?

mlucool avatar May 23 '22 23:05 mlucool

Happy to review a PR on this, if you want to have a crack at it! Though it might require modifications to the C extension, i don't know if you'd be comfortable with that?

joerick avatar May 24 '22 08:05 joerick

@joerick I took this one on. See #211. Feedback would be much appreciated

telamonian avatar Aug 17 '22 08:08 telamonian