honeycomb_kernels/grisubal/
timers.rs1#[cfg(feature = "profiling")]
6pub(crate) static mut TIMERS: [Option<std::time::Duration>; 13] = [None; 13];
8
9#[cfg(feature = "profiling")]
10pub(crate) enum Section {
12 ImportVTK = 0,
13 BuildGeometry,
14 DetectOrientation,
15 ComputeOverlappingGrid,
16 RemoveRedundantPoi,
17 BuildMeshTot,
18 BuildMeshInit,
19 BuildMeshIntersecData,
20 BuildMeshInsertIntersec,
21 BuildMeshEdgeData,
22 BuildMeshInsertEdge,
23 Clip,
24 Cleanup,
25}
26
27macro_rules! start_timer {
28 ($inst: ident) => {
29 #[cfg(feature = "profiling")]
30 let mut $inst = std::time::Instant::now();
31 };
32}
33
34pub(crate) use start_timer;
35
36macro_rules! unsafe_time_section {
37 ($inst: ident, $sec: expr) => {
38 #[allow(unused_assignments)]
39 #[cfg(feature = "profiling")]
40 unsafe {
41 timers::TIMERS[$sec as usize] = Some($inst.elapsed());
42 $inst = std::time::Instant::now();
43 }
44 };
45}
46
47pub(crate) use unsafe_time_section;
48
49macro_rules! finish {
50 ($inst: ident) => {
51 #[cfg(feature = "profiling")]
52 unsafe {
53 timers::TIMERS[timers::Section::Cleanup as usize] = Some($inst.elapsed());
54 println!(
55 "{},{},{},{},{},{},{},{},{},{},{},{},{}",
56 timers::TIMERS[0].unwrap().as_nanos(),
57 timers::TIMERS[1].unwrap().as_nanos(),
58 timers::TIMERS[2].unwrap().as_nanos(),
59 timers::TIMERS[3].unwrap().as_nanos(),
60 timers::TIMERS[4].unwrap().as_nanos(),
61 timers::TIMERS[5].unwrap().as_nanos(),
62 timers::TIMERS[6].unwrap().as_nanos(),
63 timers::TIMERS[7].unwrap().as_nanos(),
64 timers::TIMERS[8].unwrap().as_nanos(),
65 timers::TIMERS[9].unwrap().as_nanos(),
66 timers::TIMERS[10].unwrap().as_nanos(),
67 timers::TIMERS[11].unwrap().as_nanos(),
68 timers::TIMERS[12].unwrap().as_nanos(),
69 );
70 }
71 };
72}
73
74pub(crate) use finish;