File: explicit.rs

package info (click to toggle)
rust-hprof 0.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 148 kB
  • sloc: makefile: 4
file content (48 lines) | stat: -rw-r--r-- 1,071 bytes parent folder | download
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
42
43
44
45
46
47
48
extern crate hprof;

fn main() {
    let p = hprof::Profiler::new("main loop");

    loop {
        p.start_frame();

        {
            let _g = p.enter("setup");
            std::thread::sleep_ms(1);
        }
        {
            let _g = p.enter("physics");

            let _g = p.enter("collision");
            std::thread::sleep_ms(1);
            drop(_g);

            let _g = p.enter("update positions");
            std::thread::sleep_ms(1);
            drop(_g);
        }
        {
            let _g = p.enter("render");

            let _g = p.enter("cull");
            std::thread::sleep_ms(1);
            drop(_g);

            let _g = p.enter("gpu submit");
            std::thread::sleep_ms(2);
            drop(_g);

            let _g = p.enter("gpu wait");
            std::thread::sleep_ms(10);
        }

        p.end_frame();

        // this would usually depend on a debug flag, or use custom functionality for drawing the
        // debug information.
        if true {
            p.print_timing();
        }
        break;
    }
}