Skip to content

Commit d35c28a

Browse files
Merge pull request #1074 from Mark-Simulacrum/sum-bootstrap
Report total bootstrap time correctly on compare page
2 parents be279a2 + aba6802 commit d35c28a

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

site/src/api.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ pub mod comparison {
164164
pub date: Option<Date>,
165165
pub pr: Option<u32>,
166166
pub bootstrap: HashMap<String, u64>,
167+
pub bootstrap_total: u64,
167168
}
168169

169170
/// A serializable wrapper for `comparison::ArtifactData`.

site/src/comparison.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ pub struct ArtifactDescription {
442442
pub pr: Option<u32>,
443443
/// Bootstrap data in the form "$crate" -> nanoseconds
444444
pub bootstrap: HashMap<String, u64>,
445+
pub bootstrap_total: u64,
445446
}
446447

447448
type StatisticsMap = HashMap<TestCase, f64>;
@@ -460,6 +461,15 @@ impl ArtifactDescription {
460461
let bootstrap = conn
461462
.get_bootstrap_by_crate(&[conn.artifact_id(&artifact).await])
462463
.await;
464+
let bootstrap_total = bootstrap
465+
.values()
466+
.filter_map(|v| {
467+
v.get(0)
468+
.copied()
469+
.unwrap_or_default()
470+
.map(|v| v.as_nanos() as u64)
471+
})
472+
.sum::<u64>();
463473
let bootstrap = bootstrap
464474
.into_iter()
465475
.filter_map(|(k, mut v)| {
@@ -492,6 +502,7 @@ impl ArtifactDescription {
492502
pr,
493503
artifact,
494504
bootstrap,
505+
bootstrap_total,
495506
}
496507
}
497508
}
@@ -531,6 +542,7 @@ impl From<ArtifactDescription> for api::comparison::ArtifactDescription {
531542
},
532543
pr: data.pr,
533544
bootstrap: data.bootstrap,
545+
bootstrap_total: data.bootstrap_total,
534546
}
535547
}
536548
}

site/static/compare.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -610,9 +610,8 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
610610
return testCases;
611611
},
612612
bootstrapTotals() {
613-
const sum = bootstrap => Object.entries(bootstrap).map(e => e[1] / 1e9).reduce((sum, next) => sum + next, 0);
614-
const a = sum(this.data.a.bootstrap);
615-
const b = sum(this.data.b.bootstrap);
613+
const a = this.data.a.bootstrap_total / 1e9;
614+
const b = this.data.b.bootstrap_total / 1e9;
616615
return { a, b };
617616
},
618617
bootstraps() {
@@ -628,7 +627,8 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
628627
b: format(b),
629628
percent: 100 * (b - a) / a
630629
};
631-
}).sort((a, b) => Math.abs(b.percent) - Math.abs(a.percent));
630+
})
631+
.sort((a, b) => Math.abs(b.percent) - Math.abs(a.percent));
632632
},
633633
before() {
634634
if (!this.data) {
@@ -814,4 +814,4 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
814814
</script>
815815
</body>
816816

817-
</html>
817+
</html>

0 commit comments

Comments
 (0)