Hi!
I’ve finally published my first crate to crates.io: https://github.com/matklad/elapsed
It provides a single function, measureTime
, which you can use like this:
let (elapsed, sum) = measure_time(|| {
(0..10_000).sum::<u64>()
});
println!("elapsed = {}", elapsed); // prints = 227.81 μs
println!("sum = {}", sum);
The return type wraps std::Duration
to provide a useful Display
implementation, so that you can concentrate on finding the bottlenecks in the code code, and not on the extracting elapsed milliseconds from a Duration
.