Run cargo bench to measure the performance of Rust functions annotated with #[bench] and view timing statistics.
Run cargo bench to execute benchmark functions annotated with #[bench] in your Rust code. This command compiles your project in release mode and runs the benchmarks, outputting performance statistics to the terminal.
cargo bench
To run a specific benchmark, append its name to the command:
cargo bench -- my_benchmark_function
cargo bench is a tool that measures how fast your code runs by executing specific functions many times. You use it when you want to see if a change you made to your code made it faster or slower. Think of it like a stopwatch for your computer programs that tells you exactly how long a task takes.