From 01fd0bdd68ea5d19c9078abd1114467fc04fe50a Mon Sep 17 00:00:00 2001 From: Kent Ross Date: Wed, 17 Apr 2024 20:40:28 -0700 Subject: [PATCH] add directions for using the pprof feature on linux (#77) --- how_to_profile.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/how_to_profile.md b/how_to_profile.md index 234a745..ec8284e 100644 --- a/how_to_profile.md +++ b/how_to_profile.md @@ -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! \ No newline at end of file