diff --git a/crates/cargo-codspeed/README.md b/crates/cargo-codspeed/README.md index 79c6582..49535a5 100644 --- a/crates/cargo-codspeed/README.md +++ b/crates/cargo-codspeed/README.md @@ -51,3 +51,13 @@ Options: ## Advanced Usage The `vendored-openssl` feature can be used to statically link with openssl with `cargo install cargo-codspeed --features vendored-openssl`. + +## Development + +### Troubleshooting + +- Build error on MacOS: `ld: library 'git2' not found` + + ``` + brew install libgit2 + ``` diff --git a/crates/cargo-codspeed/src/app.rs b/crates/cargo-codspeed/src/app.rs index 107fa08..d6063df 100644 --- a/crates/cargo-codspeed/src/app.rs +++ b/crates/cargo-codspeed/src/app.rs @@ -43,6 +43,10 @@ enum Commands { /// Space or comma separated list of features to activate #[arg(short = 'F', long)] features: Option, + + /// Build the benchmarks with the specified profile + #[arg(long, default_value = "release")] + profile: String, }, /// Run the previously built benchmarks Run { @@ -72,6 +76,7 @@ pub fn run(args: impl Iterator) -> Result<()> { benches, package_selection, features, + profile, } => { let features = features.map(|f| { f.split(|c| c == ' ' || c == ',') @@ -83,7 +88,7 @@ pub fn run(args: impl Iterator) -> Result<()> { package_selection.exclude, package_selection.package, )?; - build_benches(&ws, benches, packages, features) + build_benches(&ws, benches, packages, features, profile) } Commands::Run { benches, diff --git a/crates/cargo-codspeed/src/build.rs b/crates/cargo-codspeed/src/build.rs index 107b7a7..6841d83 100644 --- a/crates/cargo-codspeed/src/build.rs +++ b/crates/cargo-codspeed/src/build.rs @@ -15,6 +15,7 @@ use cargo::{ fn get_compile_options( config: &Config, features: &Option>, + profile: &str, package: &Package, benches: Vec<&str>, is_root_package: bool, @@ -33,7 +34,7 @@ fn get_compile_options( .collect::>(), ); } - compile_opts.build_config.requested_profile = "release".into(); + compile_opts.build_config.requested_profile = profile.into(); compile_opts.filter = CompileFilter::from_raw_arguments( false, vec![], @@ -59,6 +60,7 @@ pub fn build_benches( selected_benches: Option>, packages: Packages, features: Option>, + profile: String, ) -> Result<()> { let packages_to_build = packages.get_packages(ws)?; let mut benches_to_build = vec![]; @@ -126,6 +128,7 @@ pub fn build_benches( let compile_opts = get_compile_options( config, &features, + &profile, bench.package, benches_names, is_root_package,