windjammer_runtime/profiling/
tracy.rs1#[cfg(feature = "tracy")]
7use tracy_client::Client;
8
9pub struct TracyZoneGuard {
13 #[cfg(feature = "tracy")]
14 _span: tracy_client::Span,
15 #[cfg(not(feature = "tracy"))]
16 _no_copy: std::marker::PhantomData<()>,
17}
18
19#[inline]
25pub fn tracy_zone(_name: &'static str) -> TracyZoneGuard {
26 #[cfg(feature = "tracy")]
27 {
28 let client = Client::start();
29 let span = client.span_alloc(Some(_name), "windjammer", file!(), line!(), 0);
30 TracyZoneGuard { _span: span }
31 }
32 #[cfg(not(feature = "tracy"))]
33 {
34 TracyZoneGuard {
35 _no_copy: std::marker::PhantomData,
36 }
37 }
38}
39
40#[cfg(test)]
41mod tests {
42 use super::*;
43
44 #[test]
45 fn tracy_zone_no_panic_without_feature() {
46 {
47 let _z = tracy_zone("unit_test_zone");
48 }
49 }
50}