#[cfg(feature = "profile-with-puffin")]
pub use puffin;
#[cfg(feature = "profile-with-optick")]
pub use optick;
#[cfg(feature = "profile-with-superluminal")]
pub use superluminal_perf;
#[cfg(feature = "profile-with-tracing")]
pub use tracing;
#[cfg(feature = "profile-with-tracing")]
pub use tracy_client;
#[macro_export]
macro_rules! scope {
($name:expr) => {
#[cfg(feature = "profile-with-puffin")]
$crate::puffin::profile_scope!($name);
#[cfg(feature = "profile-with-optick")]
$crate::optick::event!($name);
#[cfg(feature = "profile-with-superluminal")]
let _superluminal_guard = $crate::superluminal::SuperluminalGuard::new($name);
#[cfg(feature = "profile-with-tracing")]
let _span = $crate::tracing::span!(tracing::Level::INFO, $name);
#[cfg(feature = "profile-with-tracing")]
let _span_entered = _span.enter();
};
($name:expr, $data:expr) => {
#[cfg(feature = "profile-with-puffin")]
$crate::puffin::profile_scope_data!($name, $data);
#[cfg(feature = "profile-with-optick")]
$crate::optick::event!($name);
#[cfg(feature = "profile-with-optick")]
$crate::optick::tag!("tag", $data);
#[cfg(feature = "profile-with-superluminal")]
let _superluminal_guard =
$crate::superluminal::SuperluminalGuard::new_with_data($name, $data);
#[cfg(feature = "profile-with-tracing")]
let _span = $crate::tracing::span!(tracing::Level::INFO, $name, tag = $data);
#[cfg(feature = "profile-with-tracing")]
let _span_entered = _span.enter();
};
}
pub use profiling_procmacros::function;
#[macro_export]
macro_rules! register_thread {
() => {
let thread_name = std::thread::current()
.name()
.map(|x| x.to_string())
.unwrap_or_else(|| format!("Thread {:?}", std::thread::current().id()));
$crate::register_thread!(&thread_name);
};
($name:expr) => {
#[cfg(feature = "profile-with-optick")]
$crate::optick::register_thread($name);
#[cfg(feature = "profile-with-superluminal")]
$crate::superluminal_perf::set_current_thread_name($name);
#[cfg(feature = "profile-with-tracy")]
$crate::tracy_client::set_thread_name($name);
};
}
#[macro_export]
macro_rules! finish_frame {
() => {
#[cfg(feature = "profile-with-puffin")]
$crate::puffin::GlobalProfiler::lock().new_frame();
#[cfg(feature = "profile-with-optick")]
$crate::optick::next_frame();
#[cfg(feature = "profile-with-tracy")]
$crate::tracy_client::finish_continuous_frame!();
};
}
#[cfg(feature = "profile-with-superluminal")]
#[doc(hidden)]
pub mod superluminal {
pub struct SuperluminalGuard;
const DEFAULT_SUPERLUMINAL_COLOR: u32 = 0xFFFFFFFF;
impl SuperluminalGuard {
pub fn new(name: &str) -> Self {
superluminal_perf::begin_event(name);
SuperluminalGuard
}
pub fn new_with_data(
name: &str,
data: &str,
) -> Self {
superluminal_perf::begin_event_with_data(name, data, DEFAULT_SUPERLUMINAL_COLOR);
SuperluminalGuard
}
}
impl Drop for SuperluminalGuard {
fn drop(&mut self) {
superluminal_perf::end_event();
}
}
}