Skip to content

Commit 801071c

Browse files
authored
Merge pull request #1410 from rust-lang/compare-aggregations
Add data aggregations to compare page
2 parents efa8444 + b231273 commit 801071c

File tree

3 files changed

+134
-40
lines changed

3 files changed

+134
-40
lines changed

site/static/compare.html

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<div id="app">
2222
<fieldset id="settings">
2323
<legend id="search-toggle" class="section-heading">Do another comparison<span
24-
id="search-toggle-indicator"></span></legend>
24+
class="toggle-indicator" id="search-toggle-indicator"></span></legend>
2525
<div id="search-content">
2626
<div id="commits" class="section">
2727
<div class="section-heading">Commits</div>
@@ -83,8 +83,8 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
8383
<a v-bind:href="compareLink">🔎 compare commits</a>
8484
</div>
8585
</div>
86-
<fieldset id="filters">
87-
<legend id="filters-toggle" class="section-heading">Filters<span id="filters-toggle-indicator"></span>
86+
<fieldset id="filters" class="collapsible-section">
87+
<legend id="filters-toggle" class="section-heading">Filters<span class="toggle-indicator" id="filters-toggle-indicator"></span>
8888
</legend>
8989
<div id="filters-content" style="display: none;">
9090
<div class="section">
@@ -278,19 +278,26 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
278278
</div>
279279
</fieldset>
280280
<p v-if="dataLoading && !data">Loading ...</p>
281-
<div v-if="data" id="content" style="margin-top: 15px">
282-
<div id="main-summary">
283-
<summary-table :cases="filteredSummary"></summary-table>
284-
<div style="position: absolute; right: 5px; top: 5px;">
281+
<div v-if="data" id="main-summary">
282+
<summary-table :summary="filteredSummary"></summary-table>
283+
<div style="position: absolute; right: 5px; top: 5px;">
285284
<span class="tooltip" style="margin-right: 1em;">?
286285
<span class="tooltiptext">
287286
The table shows summaries of regressions, improvements and all changes
288287
calculated from data that is currently visible (data that passes the
289288
active filters).
290289
</span>
291290
</span>
292-
</div>
293291
</div>
292+
</div>
293+
<fieldset id="aggregations" class="collapsible-section">
294+
<legend id="aggregations-toggle" class="section-heading">Aggregations<span class="toggle-indicator" id="aggregations-toggle-indicator"></span>
295+
</legend>
296+
<div id="aggregations-content" v-if="data">
297+
<aggregations :cases="testCases"></aggregations>
298+
</div>
299+
</fieldset>
300+
<div v-if="data" id="content" style="margin-top: 15px">
294301
<div v-if="data.new_errors.length">
295302
<p><b>Newly broken benchmarks</b>:</p>
296303
<details v-for="[crate, error] in data.new_errors">
@@ -299,7 +306,6 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
299306
</details>
300307
<hr />
301308
</div>
302-
303309
<test-cases-table
304310
title="Primary"
305311
:cases="testCases.filter(c => c.category === 'primary')"

site/static/compare/script.js

Lines changed: 93 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ const app = Vue.createApp({
3535
loadState(state => makeData(state, app));
3636

3737
document.getElementById("filters-toggle").onclick = (e) => {
38-
toggleFilters("filters-content", "filters-toggle-indicator");
38+
toggleSection("filters-content", "filters-toggle-indicator");
3939
};
4040
document.getElementById("search-toggle").onclick = (e) => {
41-
toggleFilters("search-content", "search-toggle-indicator");
41+
toggleSection("search-content", "search-toggle-indicator");
42+
};
43+
document.getElementById("aggregations-toggle").onclick = (e) => {
44+
toggleSection("aggregations-content", "aggregations-toggle-indicator");
4245
};
4346
},
4447
data() {
@@ -420,7 +423,7 @@ const SummaryRange = {
420423
<div v-if="range.length > 0">
421424
[<SummaryPercentValue :value="range[0]" :padWidth="6" />, <SummaryPercentValue :value="range[1]" :padWidth="6" />]
422425
</div>
423-
<div v-else>-</div>
426+
<div v-else style="text-align: center;">-</div>
424427
`, components: {SummaryPercentValue}
425428
};
426429
const SummaryCount = {
@@ -434,39 +437,107 @@ const SummaryCount = {
434437
};
435438

436439
app.component('summary-table', {
437-
props: ['cases'],
440+
props: {
441+
summary: Object,
442+
withLegend: {
443+
type: Boolean,
444+
default: true
445+
}
446+
},
438447
template: `
439-
<table class="summary-table">
440-
<thead>
448+
<div v-if="summary.all.count === 0" style="flex-grow: 1; display: flex; flex-direction: column; justify-content: center;">
449+
<span>No results</span>
450+
</div>
451+
<table v-else class="summary-table">
452+
<thead v-if="withLegend">
441453
<th><!-- icon --></th>
442454
<th>Range</th>
443455
<th>Mean</th>
444456
<th>Count</th>
445457
</thead>
446458
<tbody>
447459
<tr class="positive">
448-
<td title="Regresions">❌</td>
449-
<td><SummaryRange :range="cases.regressions.range" /></td>
450-
<td><SummaryPercentValue :value="cases.regressions.average" /></td>
451-
<td><SummaryCount :cases="cases.regressions.count" :benchmarks="cases.regressions.benchmarks" /></td>
460+
<td title="Regressions" v-if="withLegend">❌</td>
461+
<template v-if="summary.regressions.count !== 0">
462+
<td><SummaryRange :range="summary.regressions.range" /></td>
463+
<td><SummaryPercentValue :value="summary.regressions.average" /></td>
464+
<td><SummaryCount :cases="summary.regressions.count" :benchmarks="summary.regressions.benchmarks" /></td>
465+
</template>
466+
<template v-else>
467+
<td colspan="3" style="text-align: center;">No regressions</td>
468+
</template>
452469
</tr>
453470
<tr class="negative">
454-
<td title="Improvements">✅</td>
455-
<td><SummaryRange :range="cases.improvements.range" /></td>
456-
<td><SummaryPercentValue :value="cases.improvements.average" /></td>
457-
<td><SummaryCount :cases="cases.improvements.count" :benchmarks="cases.improvements.benchmarks" /></td>
471+
<td title="Improvements" v-if="withLegend">✅</td>
472+
<template v-if="summary.improvements.count !== 0">
473+
<td><SummaryRange :range="summary.improvements.range" /></td>
474+
<td><SummaryPercentValue :value="summary.improvements.average" /></td>
475+
<td><SummaryCount :cases="summary.improvements.count" :benchmarks="summary.improvements.benchmarks" /></td>
476+
</template>
477+
<template v-else>
478+
<td colspan="3" style="text-align: center;">No improvements</td>
479+
</template>
458480
</tr>
459481
<tr>
460-
<td title="All changes">❌,✅</td>
461-
<td><SummaryRange :range="cases.all.range" /></td>
462-
<td><SummaryPercentValue :value="cases.all.average" /></td>
463-
<td><SummaryCount :cases="cases.all.count" :benchmarks="cases.all.benchmarks" /></td>
482+
<td title="All changes" v-if="withLegend">❌,✅</td>
483+
<td><SummaryRange :range="summary.all.range" /></td>
484+
<td><SummaryPercentValue :value="summary.all.average" /></td>
485+
<td><SummaryCount :cases="summary.all.count" :benchmarks="summary.all.benchmarks" /></td>
464486
</tr>
465487
</tbody>
466488
</table>
467489
`,
468490
components: {SummaryRange, SummaryPercentValue, SummaryCount}
469491
});
492+
493+
app.component("aggregations", {
494+
props: {
495+
cases: Array
496+
},
497+
template: `
498+
<div>
499+
<div class="aggregation-section">
500+
<div class="header">Profile</div>
501+
<div class="groups">
502+
<div class="group" v-for="profile in ['check', 'debug', 'opt', 'doc']">
503+
<div class="group-header">{{ profile }}</div>
504+
<summary-table :summary="calculateSummary('profile', profile)" :withLegend="false"></summary-table>
505+
</div>
506+
</div>
507+
</div>
508+
<div class="aggregation-section">
509+
<div class="header">Scenario</div>
510+
<div class="groups">
511+
<div class="group" v-for="scenario in ['full', 'incr-full', 'incr-unchanged', 'incr-patched']">
512+
<div class="group-header">{{ scenario }}</div>
513+
<summary-table :summary="calculateSummary('scenario', scenario)" :withLegend="false"></summary-table>
514+
</div>
515+
</div>
516+
</div>
517+
<div class="aggregation-section">
518+
<div class="header">Category</div>
519+
<div class="groups">
520+
<div class="group" v-for="category in ['primary', 'secondary']">
521+
<div class="group-header">{{ category }}</div>
522+
<summary-table :summary="calculateSummary('category', category)" :withLegend="false"></summary-table>
523+
</div>
524+
</div>
525+
</div>
526+
</div>
527+
`,
528+
methods: {
529+
calculateSummary(keyAttribute, keyValue) {
530+
const benchmarks = [];
531+
for (const benchmark of this.cases) {
532+
if (benchmark[keyAttribute] === keyValue) {
533+
benchmarks.push(benchmark);
534+
}
535+
}
536+
return computeSummary(benchmarks);
537+
}
538+
}
539+
});
540+
470541
app.mixin({
471542
methods: {
472543
percentClass(pct) {
@@ -491,7 +562,7 @@ app.mixin({
491562
}
492563
});
493564

494-
function toggleFilters(id, toggle) {
565+
function toggleSection(id, toggle) {
495566
let styles = document.getElementById(id).style;
496567
let indicator = document.getElementById(toggle);
497568
if (styles.display != "none") {
@@ -503,12 +574,9 @@ function toggleFilters(id, toggle) {
503574
}
504575
}
505576

506-
toggleFilters("filters-content", "filters-toggle-indicator");
507-
toggleFilters("search-content", "search-toggle-indicator");
508-
509-
function testCaseString(testCase) {
510-
return testCase.benchmark + "-" + testCase.profile + "-" + testCase.scenario;
511-
}
577+
toggleSection("filters-content", "filters-toggle-indicator");
578+
toggleSection("search-content", "search-toggle-indicator");
579+
toggleSection("aggregations-content", "aggregations-toggle-indicator");
512580

513581
/**
514582
* Computes summaries of improvements, regressions and all changes from the given `comparisons`.

site/static/compare/style.css

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ul li input {
1717

1818
}
1919

20-
#search-toggle-indicator {
20+
.toggle-indicator {
2121
cursor: pointer;
2222
}
2323

@@ -56,10 +56,6 @@ ul li input {
5656
margin-left: 52px;
5757
}
5858

59-
#filters-toggle {
60-
cursor: pointer;
61-
}
62-
6359
.section-heading {
6460
font-size: 16px;
6561
}
@@ -68,7 +64,7 @@ ul li input {
6864
font-size: 16px;
6965
}
7066

71-
#filters {
67+
.collapsible-section {
7268
border: 1px black;
7369
border-style: dotted;
7470
margin: 12px 0px;
@@ -308,3 +304,27 @@ input[type="checkbox"] {
308304
padding: 2px 5px;
309305
vertical-align: middle;
310306
}
307+
308+
.aggregation-section > .header {
309+
margin-top: 5px;
310+
font-size: 16px;
311+
text-align: center;
312+
}
313+
.aggregation-section > .groups {
314+
display: flex;
315+
flex-wrap: wrap;
316+
justify-content: center;
317+
}
318+
.aggregation-section .group {
319+
min-width: 45%;
320+
border: 1px dotted black;
321+
padding: 5px;
322+
margin: 10px;
323+
display: flex;
324+
flex-direction: column;
325+
align-items: center;
326+
}
327+
.aggregation-section .group-header {
328+
margin-bottom: 5px;
329+
font-weight: bold;
330+
}

0 commit comments

Comments
 (0)