Skip to content

Commit 9200fbe

Browse files
committed
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.
1 parent 19ec8c4 commit 9200fbe

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ incremental = false
4040
opt-level = 3 # <-
4141
overflow-checks = true # <-
4242

43+
[profile.test]
44+
codegen-units = 1
45+
debug = 2
46+
debug-assertions = true # <-
47+
incremental = false
48+
opt-level = 3 # <-
49+
overflow-checks = true # <-
50+
4351
[profile.release]
4452
codegen-units = 1
4553
debug = 2

0 commit comments

Comments
 (0)