profiling/lib.rs
1//
2// To use this library, enable one of the feature flags. Each backend implementation provides the
3// exact same interface. Only one may be active at a time.
4//
5
6// This library itself does not require std, but if any features are enabled, the upstream crate
7// likely will bring in std.
8#![no_std]
9
10/// Proc macro for creating a scope around each function under struct impl block
11/// ```
12/// pub struct Foo {
13/// // some data...
14/// }
15///
16/// #[profiling::all_functions]
17/// impl Foo {
18/// pub fn do_something(&self) {
19/// // some code...
20/// }
21///
22/// pub fn do_otherthing(&self) {
23/// // some code...
24/// }
25/// }
26/// ```
27///
28/// The following will generate the same code
29///
30/// ```
31/// pub struct Foo {
32/// // some data...
33/// }
34///
35/// impl Foo {
36/// #[profiling::function]
37/// pub fn do_something(&self) {
38/// // some code...
39/// }
40///
41/// #[profiling::function]
42/// pub fn do_otherthing(&self) {
43/// // some code...
44/// }
45/// }
46/// ```
47#[cfg(feature = "procmacros")]
48pub use profiling_procmacros::all_functions;
49/// Proc macro for creating a scope around the function, using the name of the function for the
50/// scope's name
51///
52/// This must be done as a proc macro because tracing requires a const string
53///
54/// ```
55/// #[profiling::function]
56/// fn my_function() {
57///
58/// }
59/// ```
60#[cfg(feature = "procmacros")]
61pub use profiling_procmacros::function;
62/// Proc macro to skip the auto_impl for the function
63/// ```
64/// pub struct Foo {
65/// // some data...
66/// }
67///
68/// #[profiling::all_functions]
69/// impl Foo {
70/// pub fn do_something(&self) {
71/// // some code...
72/// }
73///
74/// #[profiling::skip]
75/// pub fn do_otherthing(&self) {
76/// // some code...
77/// }
78/// }
79/// ```
80///
81/// The following will generate the same code
82///
83/// ```
84/// pub struct Foo {
85/// // some data...
86/// }
87///
88/// impl Foo {
89/// #[profiling::function]
90/// pub fn do_something(&self) {
91/// // some code...
92/// }
93///
94/// pub fn do_otherthing(&self) {
95/// // some code...
96/// }
97/// }
98/// ```
99#[cfg(feature = "procmacros")]
100pub use profiling_procmacros::skip;
101
102#[cfg(feature = "profile-with-puffin")]
103pub use puffin;
104#[cfg(feature = "profile-with-puffin")]
105mod puffin_impl;
106#[cfg(feature = "profile-with-puffin")]
107#[allow(unused_imports)]
108pub use puffin_impl::*;
109
110#[cfg(feature = "profile-with-optick")]
111pub use optick;
112#[cfg(feature = "profile-with-optick")]
113mod optick_impl;
114#[cfg(feature = "profile-with-optick")]
115#[allow(unused_imports)]
116pub use optick_impl::*;
117
118#[cfg(feature = "profile-with-superluminal")]
119pub use superluminal_perf;
120#[cfg(feature = "profile-with-superluminal")]
121mod superluminal_impl;
122#[cfg(feature = "profile-with-superluminal")]
123#[allow(unused_imports)]
124pub use superluminal_impl::*;
125
126#[cfg(feature = "profile-with-tracing")]
127pub use tracing;
128#[cfg(feature = "profile-with-tracing")]
129mod tracing_impl;
130#[cfg(feature = "profile-with-tracing")]
131#[allow(unused_imports)]
132pub use tracing_impl::*;
133
134#[cfg(feature = "profile-with-tracy")]
135pub use tracy_client;
136#[cfg(feature = "profile-with-tracy")]
137mod tracy_impl;
138#[cfg(feature = "profile-with-tracy")]
139#[allow(unused_imports)]
140pub use tracy_impl::*;
141
142#[cfg(feature = "type-check")]
143mod type_check_impl;
144#[cfg(feature = "type-check")]
145#[allow(unused_imports)]
146pub use type_check_impl::*;
147
148#[cfg(not(any(
149 feature = "profile-with-puffin",
150 feature = "profile-with-optick",
151 feature = "profile-with-superluminal",
152 feature = "profile-with-tracing",
153 feature = "profile-with-tracy",
154 feature = "type-check"
155)))]
156mod empty_impl;
157
158#[cfg(not(any(
159 feature = "profile-with-puffin",
160 feature = "profile-with-optick",
161 feature = "profile-with-superluminal",
162 feature = "profile-with-tracing",
163 feature = "profile-with-tracy",
164 feature = "type-check"
165)))]
166#[allow(unused_imports)]
167pub use empty_impl::*;