Skip to content

Commit

Permalink
add directions for using the pprof feature on linux (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
mumbleskates authored Apr 18, 2024
1 parent 520d3be commit 01fd0bd
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions how_to_profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ installed for it.
analyzed.
9. Select the areas of the diagnostics session when your benchmark is running to analyze.

## Linux

With the "pprof" feature enabled, the Criterion benchmarking library can be used
to automatically output profiles with flamegraphs for each benchmark. Simply run
the desired benchmarks while passing `--profile-time=10` or similar to the
benchmark binary. (Passing this argument probably requires specifying the
"bench" benchmark specifically, as other test binaries that cargo thinks might
have benchmarks in them do not understand the flag.)

Example command: `cargo bench --bench bench --no-default-features --features fooencoder,pprof -- 'minecraft_savedata/fooencoder/serialize' --profile-time=10`

This will run the "minecraft_savedata/fooencoder/serialize" benchmark and
profile it, then save a flamegraph of the profile results as a `.svg` file to
`target/criterion/minecraft_savedata_fooencoder/serialize/profile/flamegraph.svg`.

## Other platforms

Know how to profile these benchmarks on other platforms? Open a pull request!

0 comments on commit 01fd0bd

Please sign in to comment.