From 9200fbe95d2bad5266ad45a048d5095b26f2e1df Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Wed, 24 Feb 2021 14:43:35 +0100 Subject: [PATCH] also enable optimizations in the `test` profile Cargo doc says: > Note that when using the cargo test and cargo bench commands, the test/bench profiles only apply to the final test executable. Dependencies will continue to use the dev/release profiles. So with the current settings, `cargo test` optimizes all dependencies but not the top level crate (e.g. `test/foo.rs`) This commit adds optimizations to the last `rustc` invocation of `cargo test`. This results in a 6% reduction in binary size when doing `cargo test` on our sample test file. --- Cargo.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 6c72b7d..f64cd93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,6 +40,14 @@ incremental = false opt-level = 3 # <- overflow-checks = true # <- +[profile.test] +codegen-units = 1 +debug = 2 +debug-assertions = true # <- +incremental = false +opt-level = 3 # <- +overflow-checks = true # <- + [profile.release] codegen-units = 1 debug = 2