Skip to content

Commit c375748

Browse files
committed
Add data aggregations per profile, scenario and category to compare page
1 parent efa8444 commit c375748

File tree

3 files changed

+116
-34
lines changed

3 files changed

+116
-34
lines changed

site/static/compare.html

Lines changed: 11 additions & 4 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">
@@ -277,10 +277,17 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
277277
<button @click="resetFilter">Reset filters</button>
278278
</div>
279279
</fieldset>
280+
<fieldset id="aggregations" class="collapsible-section">
281+
<legend id="aggregations-toggle" class="section-heading">Aggregations<span class="toggle-indicator" id="aggregations-toggle-indicator"></span>
282+
</legend>
283+
<div id="aggregations-content" v-if="data">
284+
<aggregations :cases="testCases"></aggregations>
285+
</div>
286+
</fieldset>
280287
<p v-if="dataLoading && !data">Loading ...</p>
281288
<div v-if="data" id="content" style="margin-top: 15px">
282289
<div id="main-summary">
283-
<summary-table :cases="filteredSummary"></summary-table>
290+
<summary-table :summary="filteredSummary"></summary-table>
284291
<div style="position: absolute; right: 5px; top: 5px;">
285292
<span class="tooltip" style="margin-right: 1em;">?
286293
<span class="tooltiptext">

site/static/compare/script.js

Lines changed: 79 additions & 24 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,94 @@ 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: `
439448
<table class="summary-table">
440-
<thead>
449+
<thead v-if="withLegend">
441450
<th><!-- icon --></th>
442451
<th>Range</th>
443452
<th>Mean</th>
444453
<th>Count</th>
445454
</thead>
446455
<tbody>
447456
<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>
457+
<td title="Regresions" v-if="withLegend">❌</td>
458+
<td><SummaryRange :range="summary.regressions.range" /></td>
459+
<td><SummaryPercentValue :value="summary.regressions.average" /></td>
460+
<td><SummaryCount :cases="summary.regressions.count" :benchmarks="summary.regressions.benchmarks" /></td>
452461
</tr>
453462
<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>
463+
<td title="Improvements" v-if="withLegend">✅</td>
464+
<td><SummaryRange :range="summary.improvements.range" /></td>
465+
<td><SummaryPercentValue :value="summary.improvements.average" /></td>
466+
<td><SummaryCount :cases="summary.improvements.count" :benchmarks="summary.improvements.benchmarks" /></td>
458467
</tr>
459468
<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>
469+
<td title="All changes" v-if="withLegend">❌,✅</td>
470+
<td><SummaryRange :range="summary.all.range" /></td>
471+
<td><SummaryPercentValue :value="summary.all.average" /></td>
472+
<td><SummaryCount :cases="summary.all.count" :benchmarks="summary.all.benchmarks" /></td>
464473
</tr>
465474
</tbody>
466475
</table>
467476
`,
468477
components: {SummaryRange, SummaryPercentValue, SummaryCount}
469478
});
479+
480+
app.component("aggregations", {
481+
props: {
482+
cases: Array
483+
},
484+
template: `
485+
<div>
486+
<div class="aggregation-section">
487+
<div class="header">Profile</div>
488+
<div class="groups">
489+
<div class="group" v-for="profile in ['check', 'debug', 'opt', 'doc']">
490+
<div class="group-header">{{ profile }}</div>
491+
<summary-table :summary="calculateSummary('profile', profile)" :withLegend="false"></summary-table>
492+
</div>
493+
</div>
494+
</div>
495+
<div class="aggregation-section">
496+
<div class="header">Scenario</div>
497+
<div class="groups">
498+
<div class="group" v-for="scenario in ['full', 'incr-full', 'incr-unchanged', 'incr-patched']">
499+
<div class="group-header">{{ scenario }}</div>
500+
<summary-table :summary="calculateSummary('scenario', scenario)" :withLegend="false"></summary-table>
501+
</div>
502+
</div>
503+
</div>
504+
<div class="aggregation-section">
505+
<div class="header">Category</div>
506+
<div class="groups">
507+
<div class="group" v-for="category in ['primary', 'secondary']">
508+
<div class="group-header">{{ category }}</div>
509+
<summary-table :summary="calculateSummary('category', category)" :withLegend="false"></summary-table>
510+
</div>
511+
</div>
512+
</div>
513+
</div>
514+
`,
515+
methods: {
516+
calculateSummary(keyAttribute, keyValue) {
517+
const benchmarks = [];
518+
for (const benchmark of this.cases) {
519+
if (benchmark[keyAttribute] === keyValue) {
520+
benchmarks.push(benchmark);
521+
}
522+
}
523+
return computeSummary(benchmarks);
524+
}
525+
}
526+
});
527+
470528
app.mixin({
471529
methods: {
472530
percentClass(pct) {
@@ -491,7 +549,7 @@ app.mixin({
491549
}
492550
});
493551

494-
function toggleFilters(id, toggle) {
552+
function toggleSection(id, toggle) {
495553
let styles = document.getElementById(id).style;
496554
let indicator = document.getElementById(toggle);
497555
if (styles.display != "none") {
@@ -503,12 +561,9 @@ function toggleFilters(id, toggle) {
503561
}
504562
}
505563

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-
}
564+
toggleSection("filters-content", "filters-toggle-indicator");
565+
toggleSection("search-content", "search-toggle-indicator");
566+
toggleSection("aggregations-content", "aggregations-toggle-indicator");
512567

513568
/**
514569
* 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)