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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! Internal profiling helpers.
//!
//! All instrumentation in this crate goes through the `profile_span!` macro
//! exported from the crate root. With the `tracing` Cargo feature **off** the
//! macro expands to nothing, so there is zero overhead in default builds.
//!
//! # Cargo features
//!
//! | Feature | Effect |
//! |---------|--------|
//! | (none) | All `profile_span!` invocations compile to nothing. |
//! | `tracing` | Hot paths emit `tracing` spans. Consumers attach their own subscriber. |
//! | `tracy` | Implies `tracing`, plus a helper `init_tracy` that sets up a `tracing-tracy` subscriber for live profiling with a Tracy client. |
//!
//! # Usage
//!
//! ```rust,ignore
//! use voxel_framework::profile_span;
//!
//! pub fn hot_path() {
//! profile_span!("voxel::mesh::greedy");
//! // ... work that should appear in the profile ...
//! }
//! ```
//!
//! For Tracy:
//!
//! ```rust,ignore
//! fn main() {
//! #[cfg(feature = "tracy")]
//! voxel_framework::profile::init_tracy();
//!
//! bevy::prelude::App::new()/* ... */.run();
//! }
//! ```
//!
//! [`tracing`]: https://docs.rs/tracing
//! [`tracing-tracy`]: https://docs.rs/tracing-tracy
pub use ;
/// Opens a profiling span scoped to the enclosing block.
///
/// Compiles to nothing when the `tracing` feature is disabled.
///
/// # Example
///
/// ```rust,ignore
/// use voxel_framework::profile_span;
///
/// fn generate() {
/// profile_span!("voxel::mesh::greedy");
/// // expensive work
/// }
/// ```
/// Installs a `tracing` subscriber that forwards spans to a Tracy client.
///
/// Call this **once** from your binary's `main()` **before** constructing the
/// Bevy [`App`](bevy::app::App). The function is intentionally not auto-invoked
/// because most games already register their own subscriber and only one global
/// subscriber may be active at a time.
///
/// # Panics
///
/// Panics if a global default subscriber has already been installed.