#[macro_export]
macro_rules! profile_scope {
($name:expr) => {
#[cfg(feature = "profiling")]
puffin::profile_scope!($name);
};
}
#[macro_export]
macro_rules! profile_function {
() => {
#[cfg(feature = "profiling")]
puffin::profile_function!();
};
}
#[inline]
pub fn profile_operation<T, F>(#[allow(unused_variables)] name: &str, f: F) -> T
where
F: FnOnce() -> T,
{
#[cfg(feature = "profiling")]
{
puffin::profile_scope!(name);
f()
}
#[cfg(not(feature = "profiling"))]
f()
}
#[cfg(feature = "profiling")]
pub fn init_profiling() {
puffin::set_scopes_on(true);
}
#[cfg(not(feature = "profiling"))]
pub fn init_profiling() {
}
#[cfg(feature = "profiling")]
pub fn get_profiling_data() -> Vec<puffin::FrameData> {
puffin::GlobalProfiler::lock().new_frames()
}
#[cfg(not(feature = "profiling"))]
pub fn get_profiling_data() -> Vec<()> {
Vec::new()
}