I'm a complete noob in Rust, I just started to learn this.
After playing with some basics I wanted to test how fast is Rust std and do a benchmark for fun. In examples I've seen #[bench]
used, so I just checked if it's that simple.
But well...
It does not compile:
error: use of unstable library feature 'test':
bench
is a part of custom test frameworks which are unstable
That makes me ask the question: what is the proper way to benchmark things in Rust? BTW, does cargo bench
benchmarks optimized code or debug build, or is there a way to tell it which build I want to benchmark?
I assume the way I tried to use is deprecated and that's not how you do it in 2021. There ARE similar questions, but the answers are pretty old. I don't want to learn old, deprecated ways and trying to forcibly make them work.
There's a cargo command bench
, it's doc has the example with #[bench]
, yet when I just paste the example I get the error. What's going on here?