in resctl-bench/src/bench/iocost_tune/graph.rs [24:107]
fn setup_view(
vrate_range: (f64, f64),
sel: &DataSel,
series: &DataSeries,
mem_profile: u32,
isol_pct: &str,
extra_info: Option<&str>,
) -> (ContinuousView, f64) {
let (val_min, val_max) = series
.points
.iter()
.chain(series.outliers.iter())
.fold((std::f64::MAX, 0.0_f64), |acc, point| {
(acc.0.min(point.y), acc.1.max(point.y))
});
let (ymin, yscale) = match sel {
DataSel::MOF => {
let ymin = if val_min >= 1.0 {
1.0
} else {
val_min - (val_max - val_min) / 10.0
};
(ymin, 1.0)
}
DataSel::AMOF => {
let ymin = if val_min >= 1.0 {
1.0
} else {
val_min - (val_max - val_min) / 10.0
};
(ymin, 1.0)
}
DataSel::AMOFDelta => (0.0, 1.0),
DataSel::Isol => (0.0, 100.0),
DataSel::IsolPct(_) => (0.0, 100.0),
DataSel::IsolMean => (0.0, 100.0),
DataSel::LatImp => (0.0, 100.0),
DataSel::WorkCsv => (0.0, 100.0),
DataSel::Missing => (0.0, 100.0),
DataSel::RLat(_, _) => (0.0, 1000.0),
DataSel::WLat(_, _) => (0.0, 1000.0),
};
let ymax = (val_max * 1.1).max((ymin) + 0.000001);
let lines = &series.lines;
let mut xlabel = format!(
"vrate {:.1}-{:.1} (",
series.lines.range.0, series.lines.range.1
);
if lines.left.y == lines.right.y {
xlabel += &format!("mean={:.3} ", lines.left.y * yscale)
} else {
xlabel += &format!(
"min={:.3} max={:.3} ",
lines.left.y.min(lines.right.y) * yscale,
lines.left.y.max(lines.right.y) * yscale
)
}
if lines.left.x > series.lines.range.0 {
xlabel += &format!("L-infl={:.1} ", lines.left.x);
}
if lines.right.x < series.lines.range.1 {
xlabel += &format!("R-infl={:.1} ", lines.right.x);
}
xlabel += &format!("err={:.3})", series.error * yscale);
let mut ylabel = match sel {
DataSel::MOF | DataSel::AMOF | DataSel::AMOFDelta => format!("{}@{}", sel, mem_profile),
DataSel::Isol => format!("isol-{}", isol_pct),
sel => format!("{}", sel),
};
if extra_info.is_some() {
ylabel += &format!(" ({})", extra_info.as_ref().unwrap());
}
let view = ContinuousView::new()
.x_range(0.0, (vrate_range.1 * 1.1).max(0.000001))
.y_range(ymin * yscale, ymax * yscale)
.x_label(xlabel)
.y_label(ylabel);
(view, yscale)
}