rustrust-cargoflamegraph

Why is 'cargo flamegraph' running about 45x faster than cargo run (after cargo build --release)?


Until this morning, 'cargo flamegraph' was a bit slower than 'cargo run' after 'cargo build --release'.

I made a small change, swapping out:

std::collections::{HashMap, HashSet};

with:

rustc_hash::{FxHashMap, FxHashSet};

But, I can't think why this (or anything really) could possibly cause 'cargo flamegraph' to suddenly and dramatically outperform 'cargo run'.


Solution

  • cargo run will build in debug mode and run that.

    If you want to run release, either use the artifact target/release/project_name[.exe], or execute cargo run --release.