Skip to main content

hotpath_meta/
lib_off.rs

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, log = true) => {
147        $fut
148    };
149}
150
151pub use crate::Format;
152
153pub struct MeasurementGuard {}
154
155impl MeasurementGuard {
156    pub fn new(_name: &'static str, _wrapper: bool, _unsupported_async: bool) -> Self {
157        Self {}
158    }
159
160    pub fn build(_name: &'static str, _wrapper: bool, _is_async: bool) -> Self {
161        Self {}
162    }
163
164    pub fn build_with_timeout(self, _duration: std::time::Duration) {}
165}
166
167pub struct MeasurementGuardWithLog {}
168
169impl MeasurementGuardWithLog {
170    pub fn new(_name: &'static str, _wrapper: bool, _unsupported_async: bool) -> Self {
171        Self {}
172    }
173
174    pub fn build(_name: &'static str, _wrapper: bool, _is_async: bool) -> Self {
175        Self {}
176    }
177
178    pub fn finish_with_result<T: std::fmt::Debug>(self, _result: &T) {}
179}
180
181#[inline]
182pub fn measure_with_log<T: std::fmt::Debug, F: FnOnce() -> T>(
183    _name: &'static str,
184    _wrapper: bool,
185    _is_async: bool,
186    f: F,
187) -> T {
188    f()
189}
190
191pub async fn measure_with_log_async<T: std::fmt::Debug, F, Fut>(_name: &'static str, f: F) -> T
192where
193    F: FnOnce() -> Fut,
194    Fut: std::future::Future<Output = T>,
195{
196    f().await
197}
198
199pub struct HotPath;
200
201impl Default for HotPath {
202    fn default() -> Self {
203        Self::new()
204    }
205}
206
207impl HotPath {
208    pub fn new() -> Self {
209        Self {}
210    }
211}
212
213pub struct FunctionsGuardBuilder {}
214
215impl FunctionsGuardBuilder {
216    pub fn new(_caller_name: impl Into<String>) -> Self {
217        Self {}
218    }
219
220    pub fn percentiles(self, _percentiles: &[u8]) -> Self {
221        self
222    }
223
224    pub fn format(self, _format: Format) -> Self {
225        self
226    }
227
228    pub fn limit(self, _limit: usize) -> Self {
229        self
230    }
231
232    pub fn output_path(self, _path: impl AsRef<std::path::Path>) -> Self {
233        self
234    }
235
236    pub fn build(self) -> HotPath {
237        HotPath
238    }
239
240    pub fn build_with_timeout(self, _duration: std::time::Duration) -> HotPath {
241        HotPath
242    }
243}
244
245#[derive(Debug, Clone)]
246pub struct FunctionStats {}
247
248pub mod channels {
249    use super::Format;
250
251    #[derive(Debug, Clone, Copy, PartialEq, Eq)]
252    pub enum ChannelType {
253        Bounded(usize),
254        Unbounded,
255        Oneshot,
256    }
257
258    pub struct ChannelsGuardBuilder;
259
260    impl ChannelsGuardBuilder {
261        pub fn new() -> Self {
262            Self
263        }
264        pub fn format(self, _format: Format) -> Self {
265            self
266        }
267        pub fn output_path(self, _path: impl AsRef<std::path::Path>) -> Self {
268            self
269        }
270        pub fn build(self) -> ChannelsGuard {
271            ChannelsGuard
272        }
273    }
274
275    impl Default for ChannelsGuardBuilder {
276        fn default() -> Self {
277            Self::new()
278        }
279    }
280
281    pub struct ChannelsGuard;
282
283    impl ChannelsGuard {
284        pub fn new() -> Self {
285            Self
286        }
287        pub fn format(self, _format: Format) -> Self {
288            self
289        }
290        pub fn output_path(self, _path: impl AsRef<std::path::Path>) -> Self {
291            self
292        }
293    }
294
295    impl Default for ChannelsGuard {
296        fn default() -> Self {
297            Self::new()
298        }
299    }
300
301    impl Drop for ChannelsGuard {
302        fn drop(&mut self) {}
303    }
304}
305
306pub mod streams {
307    use super::Format;
308
309    pub struct StreamsGuardBuilder;
310
311    impl StreamsGuardBuilder {
312        pub fn new() -> Self {
313            Self
314        }
315        pub fn format(self, _format: Format) -> Self {
316            self
317        }
318        pub fn output_path(self, _path: impl AsRef<std::path::Path>) -> Self {
319            self
320        }
321        pub fn build(self) -> StreamsGuard {
322            StreamsGuard
323        }
324    }
325
326    impl Default for StreamsGuardBuilder {
327        fn default() -> Self {
328            Self::new()
329        }
330    }
331
332    pub struct StreamsGuard;
333
334    impl StreamsGuard {
335        pub fn new() -> Self {
336            Self
337        }
338        pub fn format(self, _format: Format) -> Self {
339            self
340        }
341        pub fn output_path(self, _path: impl AsRef<std::path::Path>) -> Self {
342            self
343        }
344    }
345
346    impl Default for StreamsGuard {
347        fn default() -> Self {
348            Self::new()
349        }
350    }
351
352    impl Drop for StreamsGuard {
353        fn drop(&mut self) {}
354    }
355}
356
357pub mod futures {
358    use super::Format;
359
360    pub struct FuturesGuardBuilder;
361
362    impl FuturesGuardBuilder {
363        pub fn new() -> Self {
364            Self
365        }
366        pub fn format(self, _format: Format) -> Self {
367            self
368        }
369        pub fn output_path(self, _path: impl AsRef<std::path::Path>) -> Self {
370            self
371        }
372        pub fn build(self) -> FuturesGuard {
373            FuturesGuard
374        }
375    }
376
377    impl Default for FuturesGuardBuilder {
378        fn default() -> Self {
379            Self::new()
380        }
381    }
382
383    pub struct FuturesGuard;
384
385    impl FuturesGuard {
386        pub fn new() -> Self {
387            Self
388        }
389        pub fn format(self, _format: Format) -> Self {
390            self
391        }
392        pub fn output_path(self, _path: impl AsRef<std::path::Path>) -> Self {
393            self
394        }
395    }
396
397    impl Default for FuturesGuard {
398        fn default() -> Self {
399            Self::new()
400        }
401    }
402
403    impl Drop for FuturesGuard {
404        fn drop(&mut self) {}
405    }
406}