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

Useful frames hidden #62

Closed
asmeurer opened this issue Mar 15, 2019 · 5 comments
Closed

Useful frames hidden #62

asmeurer opened this issue Mar 15, 2019 · 5 comments

Comments

@asmeurer
Copy link
Contributor

I am trying to profile some SymPy code. However, the output hides all the useful information in "hidden frames".

# test.py
from sympy import symbols, Min
x = symbols('x:50')
Min(*x)
  _     ._   __/__   _ _  _  _ _/_   Recorded: 23:10:12  Samples:  2312
 /_//_/// /_\ / //_// / //_'/ //     Duration: 3.560     CPU time: 3.540
/   _/                      v3.0.1

Program: test.py

3.559 <module>  test.py:1
├─ 3.062 __new__  sympy/functions/elementary/miscellaneous.py:341
│     [1798 frames hidden]  sympy, random
└─ 0.497 <module>  sympy/__init__.py:12
      [751 frames hidden]  sympy, inspect, enum, re, collections...

To view this report with different options, run:
    pyinstrument --load-prev 2019-03-14T23-10-12 [options]
@mikedh
Copy link

mikedh commented Mar 20, 2019

Hey, great package thanks for releasing it!

I'd also like to expand the hidden frames through the Python API. In the changelog:
Hidden code is controlled by the --hide or --hide-regex options - matching on the path of the code files.

How would one do that through the Python API? I checked the args for Profiler, profiler.start, and profiler.output_text, and none of them seemed to have an option for "show me all the things."

@joerick
Copy link
Owner

joerick commented Mar 20, 2019

@asmeurer if you're interested in profiling a library that's installed into your environment, try using --show-all on the command line.

@mikedh it's true that the python API could use some love (specifically documentation)! But in your case, it would be something like:

from pyinstrument import Profiler
from pyinstrument.renderers import ConsoleRenderer

profiler = Profiler()
profiler.start()

# code you want to profile

session = profiler.stop()
profile_renderer = ConsoleRenderer(unicode=True, color=True, show_all=True)

print(profile_renderer.render(session))

@joerick
Copy link
Owner

joerick commented Apr 6, 2019

Hi @asmeurer - FYI I just released an update to make this a little easier.

You can now do pyinstrument --show '*/sympy/*' test.py and Pyinstrument will show that library's frames while still hiding others.

@joerick joerick closed this as completed Apr 6, 2019
@asmeurer
Copy link
Contributor Author

asmeurer commented Apr 7, 2019

How does pyinstrument determine which frames are useful or not?

@joerick
Copy link
Owner

joerick commented Apr 7, 2019

Normally, using the default --hide param */lib/*. if those files are in a path that contains /lib/, they are considered to be third party libraries. This catches anything that has been installed by pip and hides it.

Does that make sense for how you're using it? Let me know if it doesn't fit your use case.

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