took

Function took 

Source
pub fn took<T, F>(f: F) -> (Took, T)
where F: FnOnce() -> T,
Expand description

Measure run time of given function, return elapsed time.

Returns Took along with the function result.

Examples found in repository?
examples/function.rs (lines 5-8)
3pub fn main() {
4    // Time the given function
5    let (took, _result) = took(|| {
6        // Simulate heavy task running 1 second
7        std::thread::sleep(std::time::Duration::from_secs(1));
8    });
9
10    // Report elapsed time in human readable format
11    println!("Done, took {}", took);
12}