1pub use hotpath_macros_meta::{future_fn, main, measure, measure_all, skip};
2
3#[macro_export]
4macro_rules! measure_block {
5 ($label:expr, $expr:expr) => {{
6 $expr
7 }};
8}
9
10#[macro_export]
11macro_rules! dbg {
12 ($val:expr $(,)?) => {
13 match $val {
14 tmp => tmp
15 }
16 };
17 ($($val:expr),+ $(,)?) => {
18 ($($crate::dbg!($val)),+,)
19 };
20}
21
22#[macro_export]
23macro_rules! val {
24 ($key:expr) => {{
25 $crate::ValHandle
26 }};
27}
28
29pub struct ValHandle;
30
31impl ValHandle {
32 #[inline]
33 pub fn set<T: std::fmt::Debug>(&self, _value: &T) {}
34}
35
36pub use crate::shared::IntoF64;
37
38#[macro_export]
39macro_rules! gauge {
40 ($key:expr) => {{
41 $crate::GaugeHandle
42 }};
43}
44
45pub struct GaugeHandle;
46
47impl GaugeHandle {
48 #[inline]
49 pub fn set(&self, _value: impl IntoF64) -> &Self {
50 self
51 }
52
53 #[inline]
54 pub fn inc(&self, _delta: impl IntoF64) -> &Self {
55 self
56 }
57
58 #[inline]
59 pub fn dec(&self, _delta: impl IntoF64) -> &Self {
60 self
61 }
62}
63
64#[macro_export]
65macro_rules! channel {
66 ($expr:expr) => {
67 $expr
68 };
69 ($expr:expr, label = $label:expr) => {
70 $expr
71 };
72 ($expr:expr, capacity = $capacity:expr) => {
73 $expr
74 };
75 ($expr:expr, label = $label:expr, capacity = $capacity:expr) => {
76 $expr
77 };
78 ($expr:expr, capacity = $capacity:expr, label = $label:expr) => {
79 $expr
80 };
81 ($expr:expr, log = true) => {
82 $expr
83 };
84 ($expr:expr, label = $label:expr, log = true) => {
85 $expr
86 };
87 ($expr:expr, log = true, label = $label:expr) => {
88 $expr
89 };
90 ($expr:expr, capacity = $capacity:expr, log = true) => {
91 $expr
92 };
93 ($expr:expr, log = true, capacity = $capacity:expr) => {
94 $expr
95 };
96 ($expr:expr, label = $label:expr, capacity = $capacity:expr, log = true) => {
97 $expr
98 };
99 ($expr:expr, label = $label:expr, log = true, capacity = $capacity:expr) => {
100 $expr
101 };
102 ($expr:expr, capacity = $capacity:expr, label = $label:expr, log = true) => {
103 $expr
104 };
105 ($expr:expr, capacity = $capacity:expr, log = true, label = $label:expr) => {
106 $expr
107 };
108 ($expr:expr, log = true, label = $label:expr, capacity = $capacity:expr) => {
109 $expr
110 };
111 ($expr:expr, log = true, capacity = $capacity:expr, label = $label:expr) => {
112 $expr
113 };
114}
115
116#[macro_export]
117macro_rules! stream {
118 ($expr:expr) => {
119 $expr
120 };
121 ($expr:expr, label = $label:expr) => {
122 $expr
123 };
124 ($expr:expr, log = true) => {
125 $expr
126 };
127 ($expr:expr, label = $label:expr, log = true) => {
128 $expr
129 };
130 ($expr:expr, log = true, label = $label:expr) => {
131 $expr
132 };
133}
134
135#[macro_export]
136macro_rules! tokio_runtime {
137 () => {};
138 ($handle:expr) => {};
139}
140
141#[macro_export]
142macro_rules! future {
143 ($fut:expr) => {
144 $fut
145 };
146 ($fut:expr, label = $label:expr) => {
147 $fut
148 };
149 ($fut:expr, log = true) => {
150 $fut
151 };
152 ($fut:expr, label = $label:expr, log = true) => {
153 $fut
154 };
155 ($fut:expr, log = true, label = $label:expr) => {
156 $fut
157 };
158}
159
160pub use crate::Format;
161pub use crate::Section;
162
163pub struct MeasurementGuard {}
164
165impl MeasurementGuard {
166 pub fn new(_name: &'static str, _wrapper: bool, _is_async: bool) -> Self {
167 Self {}
168 }
169
170 pub fn build(_name: &'static str, _wrapper: bool, _is_async: bool) -> Self {
171 Self {}
172 }
173}
174
175pub struct MeasurementGuardWithLog {}
176
177impl MeasurementGuardWithLog {
178 pub fn new(_name: &'static str, _wrapper: bool, _is_async: bool) -> Self {
179 Self {}
180 }
181
182 pub fn build(_name: &'static str, _wrapper: bool, _is_async: bool) -> Self {
183 Self {}
184 }
185
186 pub fn finish_with_result<T: std::fmt::Debug>(self, _result: &T) {}
187}
188
189#[inline]
190pub fn measure_with_log<T: std::fmt::Debug, F: FnOnce() -> T>(
191 _name: &'static str,
192 _wrapper: bool,
193 f: F,
194) -> T {
195 f()
196}
197
198pub async fn measure_with_log_async<T: std::fmt::Debug, F, Fut>(_name: &'static str, f: F) -> T
199where
200 F: FnOnce() -> Fut,
201 Fut: std::future::Future<Output = T>,
202{
203 f().await
204}
205
206pub struct HotpathGuard;
207
208impl Default for HotpathGuard {
209 fn default() -> Self {
210 Self::new()
211 }
212}
213
214impl HotpathGuard {
215 pub fn new() -> Self {
216 Self {}
217 }
218}
219
220pub struct HotpathGuardBuilder {}
221
222impl HotpathGuardBuilder {
223 pub fn new(_caller_name: &'static str) -> Self {
224 Self {}
225 }
226
227 pub fn percentiles(self, _percentiles: &[u8]) -> Self {
228 self
229 }
230
231 pub fn format(self, _format: Format) -> Self {
232 self
233 }
234
235 pub fn with_functions_limit(self, _limit: usize) -> Self {
236 self
237 }
238
239 pub fn with_channels_limit(self, _limit: usize) -> Self {
240 self
241 }
242
243 pub fn with_streams_limit(self, _limit: usize) -> Self {
244 self
245 }
246
247 pub fn with_futures_limit(self, _limit: usize) -> Self {
248 self
249 }
250
251 pub fn with_threads_limit(self, _limit: usize) -> Self {
252 self
253 }
254
255 pub fn output_path(self, _path: impl AsRef<std::path::Path>) -> Self {
256 self
257 }
258
259 pub fn with_sections(self, _sections: Vec<Section>) -> Self {
260 self
261 }
262
263 pub fn before_shutdown(self, _f: impl FnOnce() + Send + 'static) -> Self {
264 self
265 }
266
267 pub fn build(self) -> HotpathGuard {
268 HotpathGuard
269 }
270
271 pub fn build_with_shutdown(self, _duration: std::time::Duration) {}
272}
273
274#[derive(Debug, Clone)]
275pub struct FunctionStats {}
276
277pub mod channels {
278 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
279 pub enum ChannelType {
280 Bounded(usize),
281 Unbounded,
282 Oneshot,
283 }
284}
285
286pub mod streams {}
287
288pub mod threads {}
289
290pub mod futures {}