Skip to content

Commit 39608fb

Browse files
committed
Group all stats by test case
1 parent de61048 commit 39608fb

File tree

1 file changed

+25
-51
lines changed

1 file changed

+25
-51
lines changed

site/src/comparison.rs

Lines changed: 25 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ pub struct ArtifactData {
293293
pub bootstrap: HashMap<String, u64>,
294294
}
295295

296-
type StatisticsMap = HashMap<Benchmark, HashMap<Profile, Vec<(Scenario, f64)>>>;
296+
type StatisticsMap = HashMap<(Benchmark, Profile, Scenario), f64>;
297297

298298
impl ArtifactData {
299299
/// For the given `ArtifactId`, consume the first datapoint in each of the given `SeriesResponse`
@@ -367,33 +367,20 @@ where
367367
let benchmark = *response.path.get::<Benchmark>().unwrap();
368368
let profile = *response.path.get::<Profile>().unwrap();
369369
let scenario = *response.path.get::<Scenario>().unwrap();
370-
stats
371-
.entry(benchmark)
372-
.or_default()
373-
.entry(profile)
374-
.or_default()
375-
.push((scenario, value));
370+
stats.insert((benchmark, profile, scenario), value);
376371
}
377372
stats
378373
}
379374

380375
impl From<ArtifactData> for api::comparison::ArtifactData {
381376
fn from(data: ArtifactData) -> Self {
382-
let stats = data
383-
.statistics
384-
.into_iter()
385-
.flat_map(|(benchmark, profiles)| {
386-
profiles.into_iter().map(move |(profile, scenarios)| {
387-
(
388-
format!("{}-{}", benchmark, profile),
389-
scenarios
390-
.into_iter()
391-
.map(|(s, v)| (s.to_string(), v))
392-
.collect::<Vec<_>>(),
393-
)
394-
})
395-
})
396-
.collect();
377+
let mut stats: HashMap<String, Vec<(String, f64)>> = HashMap::new();
378+
for ((benchmark, profile, scenario), value) in data.statistics {
379+
stats
380+
.entry(format!("{}-{}", benchmark, profile))
381+
.or_default()
382+
.push((scenario.to_string(), value))
383+
}
397384
api::comparison::ArtifactData {
398385
commit: match data.artifact.clone() {
399386
ArtifactId::Commit(c) => c.sha,
@@ -452,27 +439,18 @@ impl Comparison {
452439

453440
fn get_benchmarks(&self) -> Vec<BenchmarkComparison> {
454441
let mut result = Vec::new();
455-
for (&benchmark, profiles) in self.a.statistics.iter() {
456-
for (&profile, scenarios) in profiles {
457-
if profile == Profile::Doc {
458-
continue;
459-
}
442+
for (&(benchmark, profile, scenario), &a) in self.a.statistics.iter() {
443+
if profile == Profile::Doc {
444+
continue;
445+
}
460446

461-
if let Some(b) = self.b.statistics.get(&benchmark) {
462-
if let Some(b) = b.get(&profile) {
463-
for &(scenario, a) in scenarios.iter() {
464-
if let Some(b) = b.iter().find(|(s, _)| *s == scenario).map(|(_, b)| b)
465-
{
466-
result.push(BenchmarkComparison {
467-
benchmark,
468-
profile,
469-
scenario,
470-
results: (a, *b),
471-
})
472-
}
473-
}
474-
}
475-
}
447+
if let Some(&b) = self.b.statistics.get(&(benchmark, profile, scenario)) {
448+
result.push(BenchmarkComparison {
449+
benchmark,
450+
profile,
451+
scenario,
452+
results: (a, b),
453+
})
476454
}
477455
}
478456

@@ -518,15 +496,11 @@ impl BenchmarkVariances {
518496
let mut variance_data: HashMap<String, BenchmarkVariance> = HashMap::new();
519497
for _ in previous_commits.iter() {
520498
let series_data = statistics_from_series(&mut previous_commit_series);
521-
for (bench, profiles) in series_data {
522-
for (profile, scenarios) in profiles {
523-
for (scenario, val) in scenarios {
524-
variance_data
525-
.entry(format!("{}-{}-{}", bench, profile, scenario))
526-
.or_default()
527-
.push(val);
528-
}
529-
}
499+
for ((bench, profile, scenario), value) in series_data {
500+
variance_data
501+
.entry(format!("{}-{}-{}", bench, profile, scenario))
502+
.or_default()
503+
.push(value);
530504
}
531505
}
532506
if variance_data.len() < Self::MIN_PREVIOUS_COMMITS {

0 commit comments

Comments
 (0)