use print_perf::*; 
// or explicit print_perf::{perf, Perf};
use std::time::Duration;
use std::thread::sleep;

fn add(a: i32, b: i32) -> i32 {
    sleep(Duration::from_millis(100));
    a + b
}

fn main() {
    println!("main_1()");
    main_1();
    println!("main_2()");
    main_2();
}

fn main_1() {
    let add_p = perf!("add fn");
    let result = add(4, 4);
    add_p.end();
    // ^-- prints: 0.100140446 (add fn) @ [src/main.rs:9]
    assert_eq!(result, 8);
}


fn main_2() {
    let p = perf!("add fn");
    let _result = add(4, 4);
    p.split("add");
    let _div = _result / 2;
    p.split("div");
    p.end();
}
