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

Add note about pyinstrument support wiki page #377

Merged
merged 1 commit into from
May 17, 2022
Merged

Conversation

joerick
Copy link
Contributor

@joerick joerick commented Nov 14, 2021

Hello @jlfwong !

Thanks to the efforts of @goxberry over in joerick/pyinstrument#160, my profiler pyinstrument now supports speedscope JSON as an output. I thought you might want to mention it in your README.

I couldn't create the wiki page myself, but if you're able to copy paste this as a new page into the wiki that should work:

Importing from pyinstrument (python)

pyinstrument is a statistical profiler for Python.

pyinstrument has an explicit output format for speedscope (See: https://github.com/joerick/pyinstrument/pull/160).

To profile a Python script and view the output in speedscope, run:

    pyinstrument -r speedscope -o profile.speedscope.json your_script.py

Or, you can profile a specific block of code using:

    from pyinstrument import Profiler
    from pyinstrument.renderers import SpeedscopeRenderer
    
    with Profiler() as profiler:
        ... # your code here

    with open('profile.speedscope.json', 'w') as f:
        f.write(profiler.render(renderer=SpeedscopeRenderer()))

Then drop the resulting profile.speedscope.json into https://www.speedscope.app/

@jlfwong
Copy link
Owner

jlfwong commented May 17, 2022

Thanks!

@jlfwong jlfwong merged commit 103db68 into jlfwong:main May 17, 2022
jackerghan pushed a commit to jackerghan/speedscope that referenced this pull request Jul 28, 2023
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

Successfully merging this pull request may close these issues.

2 participants