aoc_companion/
lib.rs

1use std::time::Instant;
2
3pub mod bitset;
4pub mod input;
5pub mod parse;
6pub mod point;
7pub mod range;
8
9pub fn timed<T>(f: impl FnOnce() -> T) -> T {
10    let timer = Instant::now();
11    let res = f();
12    println!("Task took {:?} to finish!", timer.elapsed());
13    res
14}
15
16#[macro_export]
17macro_rules! timer {
18    ($($arg:tt)*) => {{
19        let timer = std::time::Instant::now();
20
21        let res = {
22            $($arg)*
23        };
24
25        println!("Timer took {:?} to finish!", timer.elapsed());
26
27        res
28    }}
29}