arti-bench: Summarize statistics more othogonally
In arti-bench
We currently have these structures to capture our results:
pub struct TimingSummary {
download_ttfb_sec: f64,
download_rate_megabit: f64,
upload_ttfb_sec: f64,
upload_rate_megabit: f64,
}
// ...
pub struct BenchmarkResults {
// ...
results_mean: TimingSummary,
results_median: TimingSummary,
results_raw: Vec<TimingSummary>,
}
This leads to code size in BenchmarkResults::generate()
that grows as the product of the number of measurements (download_ttfb, upload_ttfb, etc) with the number of statistics (mean, median, etc). Because we're also adding "best" and "worst" (!293 (merged)), and because we're probably adding more measurements in the future too, this probably isn't a good situation.
I suggest that we refactor to something more like this:
pub struct ExperimentResult {
// The same as current TimingSummary
}
pub struct Statistic {
mean: f64,
median: f64,
min: f64,
max: f64,
}
pub struct BenchMarkResults {
download_ttfb_sec: Statistic,
download_rate_megabit: Statistic,
upload_ttfb_sec: Statistic
upload_rate_megabit: Statistic,
results_raw: Vec<ExperimentResult>
}
impl FromIter<f64> for Statistic { ... }
That way we can simplify our code in BenchmarkResults::generate to a few map and collect calls, and we won't have to worry (so much) about copy-paste errors.
What do you think, @eta?