Optimize BufWriter on tests


I have a big file that I have to write (around 30mb) and I've added a unit-test. I can't reduce the size of the write, since it's bound to the logic being tested.

When running tests in --release it takes 0.28s to finish, which is nice, but when running without --release it takes 5.01s, which is very long time.

I've already added this to Cargo.toml but it doesn't seems to work.

opt-level = 3

If I add:

opt-level = 3

It works fine, which makes me wonder if it's possible to optimize only std (std isn't a dependency?), since I don't like to fully optimize my code and I'll need to do some debugging also.

The standard library is pre-compiled and always optimized.

BufWriter<T> is codegenes as part of your crate as it is generic. It is not possible to only optimize a part of a crate.


Thanks! It makes sense now. Indeed if it is generic, it's impossible to optimize part of the crate.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.