Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recursive functions #293

Open
dpinol opened this issue Feb 28, 2024 · 3 comments
Open

recursive functions #293

dpinol opened this issue Feb 28, 2024 · 3 comments

Comments

@dpinol
Copy link

dpinol commented Feb 28, 2024

pyinstrument is a wonderful tool, but it's challenging to use on recursive functions

image

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

@joerick
Copy link
Owner

joerick commented Feb 28, 2024

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.

@gnuille
Copy link

gnuille commented Mar 5, 2024

I created a pull request so it can be enabled from api
#294

@joerick
Copy link
Owner

joerick commented Jun 27, 2024

You can, if you like, use the output method, e.g. profiler.output(ConsoleRenderer(flat=True)). But your PR looks good too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants