use crabgrind::callgrind;
#[non_exhaustive]
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub enum ClientRequest {
DumpStats {
reason: Option<String>,
},
ToggleCollection,
StartInstrumentation,
StopInstrumentation,
ZeroStats,
}
impl ClientRequest {
#[inline(always)]
pub fn now(self) {
match self {
Self::ZeroStats => callgrind::zero_stats(),
Self::ToggleCollection => callgrind::toggle_collect(),
Self::StartInstrumentation => callgrind::start_instrumentation(),
Self::StopInstrumentation => callgrind::stop_instrumentation(),
Self::DumpStats { reason } => {
callgrind::dump_stats(reason.as_ref().map(|s| s.as_ref()))
}
}
}
}