[−][src]Crate devtimer
Devtimer
devtimer provides a very compact yet complete benchmarking suite for code
written in Rust. It makes use of the standard library only to provide
benchmark operations. You can either use it for benchmarking a single operation or you can
use it for running an operation multiple times and finding the min, max and average execution
times. Since this crate has no external dependencies, it is small, fast and does exactly what it
claims to. Happy benchmarking!
Simple usage example
use devtimer::DevTime; fn main() { let mut devtime = DevTime::new(); devtime.start(); // Do some long operation devtime.stop(); println!("The time taken for the operation was: {} nanos", devtime.time_in_nanos().unwrap()); println!("The time taken for the operation was: {} micros", devtime.time_in_micros().unwrap()); println!("The time taken for the operation was: {} millis", devtime.time_in_millis().unwrap()); println!("The time taken for the operation was: {} secs", devtime.time_in_secs().unwrap()); }
Advanced usage example
use devtimer::DevTime; fn main() { let mut dt = DevTime::new(); // We will simulate a long operation by std::thread::sleep() // Run 10 iterations for the test let bench_result = dt.run_through(10, || { // Fake a long running operation std::thread::sleep(std::time::Duration::from_secs(1)); }); bench_result.print_stats(); }
Structs
| DevTime | The |
| RunThroughReport | The |