A crate to make it slightly easier to benchmark cargo runs under different settings.
- Install hyperfine, which we use for benchmarking. There are many ways to do it, but one is below
cargo install hyperfine
- Install mold, which might involve compiling it. See the page for details. I use Nix, which has a package for it already. It is an alternative linker for Rust programs written by @rui314. Consider sponsoring them if it works well for you
- Install cranelift, which is now included in as a rustup component in the latest nightly for x86_64 linux. Details below. It shows that it works for other platforms, see the README for details
rustup component add rustc-codegen-cranelift-preview --toolchain nightly
- Create a server-dev profile in Cargo.toml by adding the section below. Add a section to set the opt-level for your crate and its dependencies
[profile.dev]
opt-level = 0
[profile.dev.package."*"]
opt-level = 0
[profile.server-dev]
inherits="dev"
- Enable the unstable codegen-backend feature in .cargo/config.toml. If the folder or file doesn't exist, create them.
To actually enable it, you need to add
codegen-backend = "cranelift"
below the profile name, but the tool will handle this for you.
[unstable]
codegen-backend = true
[profile.server-dev]
- Run it
cargo run -- --cargo-dir=<"path_to_dir_to_compile"> --output-dir=<"path to dir to put output json files in" > --num-runs=3
- Available commands can be found
cargo run -- --help
This is currently in a very beta state. I will probably break the bin crate out into an example.