1 unstable release
0.1.0 | Jul 7, 2024 |
---|
#53 in #timing
3KB
timeit-rs
A simple, single-dependency rust crate to benchmark the exection time of a block of code
lib.rs
:
A simple, single-dependency crate to benchmark the execution time of a block of code.
Examples
Time single execution
#[macro_use]
extern crate timethis;
fn main() {
let time_taken = timethis!({
let mut x = Vec::new();
for i in 0..1000 {
x.push(i);
}
});
println!("Time taken for 1,000 pushes: {:?}", time_taken);
}
Time multiple execution
#[macro_use]
extern crate timethis;
fn main() {
let time_taken = timethis_loops!(10, {
let mut x = Vec::new();
for i in 0..1000 {
x.push(i);
}
});
println!("Time taken for 10,000 pushes: {:?}", time_taken);
}