We'll be profiling these benchmarks with Visual Studio. Make sure you have basic C/C++ payloads installed for it.
- Add the following beneath the
[[bench]]
line inCargo.toml
:[profile.bench] debug = true
- Build the benchmark without running it with
cargo bench --no-run
- Locate the benchmark binary at
target/release/deps/bench-*.exe
. If there are multiplebench
executables indeps
, you can determine which one is the most recent by deleting all of them and rebuilding. - Start Visual Studio and open a new project. Browse to the
.exe
location and open it. - Right click on the
bench-*
project in the Solution Explorer and selectProperties
. - Set the
Arguments
parameter to--bench <FILTER>
where<FILTER>
is the filter you would pass tocargo bench -- <FILTER>
. - Save the project properties and select
Debug > Performance Profiler...
. - Check
CPU Usage
and clickStart
. The benchmarks will run and upon finishing the data will be analyzed. - Select the areas of the diagnostics session when your benchmark is running to analyze.
Know how to profile these benchmarks on other platforms? Open a pull request!