1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use std::num::Wrapping;

fn heavy_calc1() -> Wrapping<u64> {
    let mut v = Wrapping(1u64);
    for i in 0..1_000_000_000 {
        v += v * Wrapping(i);
    }
    v
}

fn heavy_calc2() -> Wrapping<u64> {
    let mut v = Wrapping(1u64);
    for i in 0..800_000_000 {
        v += v * Wrapping(i);
    }
    v
}

fn big_fn() {
    // work 1

    superluminal_perf::begin_event("example-work1");
    let v = heavy_calc1();
    superluminal_perf::end_event();
    println!("work1 done: {}", v);

    // work 2

    superluminal_perf::begin_event("example-work2");
    let v = heavy_calc2();
    superluminal_perf::end_event();
    println!("work2 done: {}", v);
}

fn main() {
    println!("Enabled: {}", superluminal_perf::enabled());

    superluminal_perf::set_current_thread_name("mythread");

    big_fn();
}