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

Question: How to use/extract profiling data after running 'asv run -p' #971

Closed
s-weigand opened this issue Jun 29, 2021 · 1 comment · Fixed by #1253
Closed

Question: How to use/extract profiling data after running 'asv run -p' #971

s-weigand opened this issue Jun 29, 2021 · 1 comment · Fixed by #1253

Comments

@s-weigand
Copy link

s-weigand commented Jun 29, 2021

First of all thanks for the awesome tool ❤️

I'm wondering how to access the profiling data recorded when using asv run with the -p flag.
I can't find profiling anywhere in the generated HTML page (asv publish), nor can I find a config option or flag to add it to the HTML page (maybe I'm just blind 😅 ).

So I'm wondering what to do after recording the profiling data.

I saw that the result json files have a key profiles containing benchmark names as keys and a massive text blob as value (base64 of the pstat binary blob?).
So is the intended use to parse the result json file, decode the blob and then process it with a tool like gprof2dot?

Thanks in advance for clarifying

@mcitoler
Copy link

mcitoler commented Sep 15, 2021

In my team we figured out a way to use the profile data. It uses asv internal classes which are poorly documented but seem to work quite well:

import pstats

from asv.results import Results

results = Results.load(<file_path_to_result_json>)
profile_data_bytes = results.get_profile(<benchmark_name>)
with open(<pstats_file>, "wb") as f:
    f.write(profile_data_bytes)

p = pstats.Stats(<pstats_file>)
p.print_stats()

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 a pull request may close this issue.

2 participants