miden_debug_engine/profiling/instrument/
op_histogram_global.rs1use miden_core::operations::Operation;
2
3use super::{Instrument, InstrumentRegistration};
4use crate::profiling::{OutputResult, OutputWriter, helpers::op_histogram::OpHistogram};
5
6#[derive(Default)]
14pub struct OpHistogramGlobal {
15 hist: OpHistogram,
16}
17
18impl InstrumentRegistration for OpHistogramGlobal {
19 const NAME: &'static str = "op-histogram-global";
20
21 fn build(_config: &crate::profiling::ProfilerConfig) -> Result<Self, super::InstrumentError> {
22 Ok(Self::default())
23 }
24}
25
26#[cfg(feature = "std")]
27crate::register_instrument!(OpHistogramGlobal);
28
29impl Instrument for OpHistogramGlobal {
30 fn name(&self) -> &'static str {
31 Self::NAME
32 }
33
34 fn on_operation_execution_cycle(&mut self, op: Operation, _proc: Option<&str>) {
35 self.hist.record(op);
37 }
38
39 fn write_report_to(&self, writer: &mut dyn OutputWriter) -> OutputResult<()> {
40 writer.write_all(self.hist.report().as_bytes())
41 }
42}
43
44#[cfg(test)]
45mod tests;