canic_utils/
perf.rs

1use crate::cdk::api::performance_counter;
2use std::cell::RefCell;
3
4thread_local! {
5    pub static PERF_LAST: RefCell<u64> = RefCell::new(performance_counter(1));
6}
7
8// wrapper around performance_counter just in case
9#[must_use]
10#[allow(clippy::missing_const_for_fn)]
11pub fn perf_counter() -> u64 {
12    #[cfg(target_arch = "wasm32")]
13    {
14        performance_counter(1)
15    }
16    #[cfg(not(target_arch = "wasm32"))]
17    {
18        0
19    }
20}