Just one more thing and we're done with the lecture portion. Benchmark tests allow us to bring automation to yet another boring and repetitive task: measuring the speed of our code. This is supported by two things:
- The #[bench] annotation marks a function as a benchmark
- The standard library module test has a Bencher type, which the benchmark function uses for benchmark iterations
Unfortunately, benchmark tests are an unstable feature, so we will have to use the nightly compiler for the following. Fortunately, with rustup, moving between different versions with the rustup compiler is easy. First, we'll make sure that the nightly compiler is installed:
OK, now we can write and run a simple benchmark test. Benchmarks require Cargo, ...