magba_dev_utils/
benchmark.rs1use std::path::Path;
2
3#[derive(Debug, serde::Deserialize)]
5pub struct CriterionEstimates {
6 pub mean: CriterionMean,
7}
8
9#[derive(Debug, serde::Deserialize)]
11pub struct CriterionMean {
12 pub point_estimate: f64,
13}
14
15pub fn extract_criterion_mean(path: &Path) -> Result<f64, String> {
16 use std::fs;
17 let content =
18 fs::read_to_string(path).map_err(|e| format!("Cannot read estimates.json file: {}", e))?;
19
20 let estimates: CriterionEstimates = serde_json::from_str(&content)
21 .map_err(|e| format!("Cannot parse estimates.json file: {}", e))?;
22
23 Ok(estimates.mean.point_estimate)
24}