Function measure_and_print

Source
pub fn measure_and_print<T: Display, F: FnOnce() -> T>(f: F)
Expand description

Runs the code, and prints out the elapsed time and the result.

First prints the elapsed time to stderr, then the result to stdout, in separate lines.

§Example

use aoc_utils::measure_and_print;

measure_and_print(|| {
    (0..10_000).sum::<u64>()
});

// Prints:
// 227.81 μs
// 49995000