openvm_circuit/metrics/
mod.rsuse std::collections::BTreeMap;
use serde::{Deserialize, Serialize};
pub mod cycle_tracker;
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct VmMetrics {
pub chip_heights: Vec<(String, usize)>,
pub counts: BTreeMap<(Option<String>, String), usize>,
pub trace_cells: BTreeMap<(Option<String>, String, String), usize>,
}
#[cfg(feature = "bench-metrics")]
mod emit {
use metrics::counter;
use super::VmMetrics;
impl VmMetrics {
pub fn emit(&self) {
for (name, value) in self.chip_heights.iter() {
let labels = [("chip_name", name.clone())];
counter!("rows_used", &labels).absolute(*value as u64);
}
for ((dsl_ir, opcode), value) in self.counts.iter() {
let labels = [
("dsl_ir", dsl_ir.clone().unwrap_or_else(String::new)),
("opcode", opcode.clone()),
];
counter!("frequency", &labels).absolute(*value as u64);
}
for ((dsl_ir, opcode, air_name), value) in self.trace_cells.iter() {
let labels = [
("dsl_ir", dsl_ir.clone().unwrap_or_else(String::new)),
("opcode", opcode.clone()),
("air_name", air_name.clone()),
];
counter!("cells_used", &labels).absolute(*value as u64);
}
}
}
}