src/uu/rm/BENCHMARKING.md
Run cargo build --release before benchmarking after you make a change!
--prepare argument, since rm deletes the dir each time.hyperfine --prepare "cp -r tree tree-tmp" "target/release/coreutils rm -r tree-tmp".Hyperfine accepts multiple commands to run and will compare them. To compare performance with GNU rm
duplicate the string you passed to hyperfine but remove the target/release/coreutils bit from it.
Example: hyperfine --prepare "cp -r tree tree-tmp" "target/release/coreutils rm -rf tree-tmp" becomes
hyperfine --prepare "cp -r tree tree-tmp" "target/release/coreutils rm -rf tree-tmp" "rm -rf tree-tmp"
(This assumes GNU rm is installed as rm)
This can also be used to compare with version of rm built before your changes to ensure your change does not regress this.
Here is a bash script for doing this comparison:
#!/bin/bash
cargo build --no-default-features --features rm --release
test_dir="$1"
hyperfine --prepare "cp -r $test_dir tmp_d" "rm -rf tmp_d" "target/release/coreutils rm -rf tmp_d"
strace -c target/release/coreutils rm -rf treesamply is one option for simply creating flamegraphs. It uses the Firefox profiler as a UI.
To install:
cargo install samply
To run:
samply record target/release/coreutils rm -rf ../linux
With Cargo Flamegraph you can easily make a flamegraph of rm:
cargo flamegraph --cmd coreutils -- rm [additional parameters]