set -eux
rm -f target/release/examples/* perf.* || true
if ! grep -q debug Cargo.toml; then
cat >> Cargo.toml <<EOF
[profile.release]
debug = true
EOF
fi
cargo build --release --example "$1"
time perf record -F99 --call-graph dwarf,16384 target/release/examples/"$1" --ignored > /dev/null
perf script > perf.script
perl ~/coding/src/FlameGraph/stackcollapse-perf.pl perf.script > perf.collapsed
perl ~/coding/src/FlameGraph/flamegraph.pl perf.collapsed > perf.svg
firefox perf.svg