use miden_core::operations::Operation;
use super::{Instrument, InstrumentRegistration};
use crate::profiling::{OutputResult, OutputWriter, helpers::op_histogram::OpHistogram};
#[derive(Default)]
pub struct OpHistogramGlobal {
hist: OpHistogram,
}
impl InstrumentRegistration for OpHistogramGlobal {
const NAME: &'static str = "op-histogram-global";
fn build(_config: &crate::profiling::ProfilerConfig) -> Result<Self, super::InstrumentError> {
Ok(Self::default())
}
}
#[cfg(feature = "std")]
crate::register_instrument!(OpHistogramGlobal);
impl Instrument for OpHistogramGlobal {
fn name(&self) -> &'static str {
Self::NAME
}
fn on_operation_execution_cycle(&mut self, op: Operation, _proc: Option<&str>) {
self.hist.record(op);
}
fn write_report_to(&self, writer: &mut dyn OutputWriter) -> OutputResult<()> {
writer.write_all(self.hist.report().as_bytes())
}
}
#[cfg(test)]
mod tests;