Improve the experience with recursive functions
pyinstrument is a wonderful tool, but it's challenging to use on recursive functions
In this case, it's difficult to estimate the sum of the time spent on other functions called by the recursive functions (the ones at the bottom on the following snapshot)
Is there any way of obtaining the flat or cum times (as here) of the most sampled functions?
thanks
You could try the 'flat' option on the console renderer - e.g. pyinstrument -p flat myscript.py - that will print the output without any tree at all.
I created a pull request so it can be enabled from api https://github.com/joerick/pyinstrument/pull/294
You can, if you like, use the output method, e.g. profiler.output(ConsoleRenderer(flat=True)). But your PR looks good too.
I'm keeping this as an issue in the tracker, because it might be a good idea if the stack sampler condensed recursion into a [recursion] synthetic frame after 1-3 instances of the same frame identifier.