Skip to content

Commit d850284

Browse files
authored
Merge pull request #2 from rylev/significant
Significant
2 parents 83d3c3e + b10000c commit d850284

File tree

1 file changed

+45
-46
lines changed

1 file changed

+45
-46
lines changed

site/static/compare.html

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,17 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
280280
</li>
281281
</ul>
282282
</div>
283+
<div class="section">
284+
<div class="section-heading"><span>Show only significant changes</span>
285+
<span class="tooltip">?
286+
<span class="tooltiptext">
287+
Whether to filter out all benchmarks that do not show significant changes. A significant
288+
change is any change above 0.2% for non-noisy benchmarks and 1.0% for noisy ones.
289+
</span>
290+
</span>
291+
</div>
292+
<input type="checkbox" v-model="filter.showOnlySignificant" style="margin-left: 20px;" />
293+
</div>
283294
</div>
284295
</fieldset>
285296
<div v-if="data" id="content" style="margin-top: 15px">
@@ -288,15 +299,15 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
288299
<template v-for="bench in benches">
289300
<tr data-field-start="true">
290301
<th>
291-
<details class="toggle-table" v-on:toggle="benchGroupToggle">
302+
<details>
292303
<summary>{{ trimBenchName(bench.name) }}</summary>
293304
</details>
294305
</th>
295-
<td>avg: <span v-bind:class="percentClass(bench.avgPct)">{{bench.avgPct}}%</span></td>
296306
<td>min: <span v-bind:class="percentClass(bench.minPct)">{{bench.minPct}}%</span></td>
297307
<td>max: <span
298308
v-bind:class="percentClass(bench.maxPct)">{{bench.maxPct}}%{{isDodgyBench(bench)
299309
? "?" : ""}}</span></td>
310+
<td></td>
300311
</tr>
301312
<template v-for="run in bench.variants">
302313
<tr>
@@ -314,9 +325,9 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
314325
<td>
315326
<a
316327
v-bind:href="percentLink(data.b.commit, data.a.commit, bench.name, run.casename)">
317-
<span v-bind:class="percentClass(run.percent)">{{ run.percent }}%{{run.isDodgy ?
318-
"?"
319-
: ""}}</span>
328+
<span v-bind:class="percentClass(run.percent)">
329+
{{ run.percent }}%{{run.isDodgy ? "?" : ""}}
330+
</span>
320331
</a>
321332
</td>
322333
</tr>
@@ -373,6 +384,7 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
373384
data: {
374385
filter: {
375386
name: null,
387+
showOnlySignificant: true,
376388
cache: {
377389
full: true,
378390
incrFull: true,
@@ -419,6 +431,10 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
419431
const key = d[0];
420432
const datumA = d[1];
421433
const datumB = data.b.data[name].find(x => x[0] == key)[1];
434+
let percent = (100 * (datumB - datumA) / datumA).toFixed(1);
435+
if (percent === "-0.0") {
436+
percent = "0.0";
437+
}
422438

423439
let isDodgy = false;
424440
if (data.variance) {
@@ -430,7 +446,7 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
430446
casename: key,
431447
datumA,
432448
datumB,
433-
percent: (100 * (datumB - datumA) / datumA).toFixed(1),
449+
percent,
434450
isDodgy,
435451
});
436452
}
@@ -442,19 +458,23 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
442458
let benches =
443459
Object.keys(data.a.data).
444460
filter(n => filter.name && filter.name.trim() ? n.includes(filter.name.trim()) : true).
445-
map(name => { return { name, variants: toVariants(name) } }).filter(b => b.variants.length > 0);
446-
447-
for (let bench of benches) {
448-
let pcts = bench.variants.map(field => parseFloat(field.percent))
449-
.filter(p => p != undefined && p != null);
450-
bench.maxPct = Math.max(...pcts).toFixed(1);
451-
bench.minPct = Math.min(...pcts).toFixed(1);
452-
let sum = pcts.reduce((a, b) => a + b, 0);
453-
bench.avgPct = (sum / pcts.length).toFixed(1);
454-
bench.maxCasenameLen = Math.max(...bench.variants.map(f => f.casename.length));
455-
}
456-
const largestChange = a => Math.max(Math.abs(a.minPct), Math.abs(a.maxPct));
461+
map(name => {
462+
const variants = toVariants(name).filter(v => filter.showOnlySignificant ? isSignificant(v) : true);
463+
const pcts = variants.map(field => parseFloat(field.percent));
464+
const maxPct = Math.max(...pcts).toFixed(1);
465+
const minPct = Math.min(...pcts).toFixed(1);
466+
const maxCasenameLen = Math.max(...variants.map(f => f.casename.length));
467+
return {
468+
name,
469+
variants,
470+
maxPct,
471+
minPct,
472+
maxCasenameLen,
473+
};
474+
}).
475+
filter(b => b.variants.length > 0);
457476

477+
const largestChange = a => Math.max(Math.abs(a.minPct), Math.abs(a.maxPct));
458478
benches.sort((a, b) => largestChange(b) - largestChange(a));
459479

460480
return benches;
@@ -543,10 +563,6 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
543563
commitLink(commit) {
544564
return `https://github.com/rust-lang/rust/commit/${commit}`;
545565
},
546-
benchGroupToggle(e) {
547-
const element = e.target;
548-
toggleBenchGroup(element);
549-
},
550566
formatDate(date) {
551567
date = new Date(date);
552568
function padStr(i) {
@@ -563,34 +579,17 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
563579
}
564580
return result;
565581
},
566-
isDodgyBench(bench) {
567-
return bench.variants.some(f => f.isDodgy);
568-
},
569582
},
570-
watch: {
571-
data(newVal, oldVal) {
572-
if (newVal && !oldVal) {
573-
this.$nextTick(() => {
574-
for (let element of document.querySelectorAll(".toggle-table")) {
575-
toggleBenchGroup(element);
576-
}
577-
});
578-
}
579-
}
580-
}
581583
});
582584

583-
function toggleBenchGroup(element) {
584-
let next = element.parentElement.parentElement.nextElementSibling;
585-
let inBody = []
586-
while (next && next.getAttribute("data-field-start") !== "true") {
587-
if (element.open) {
588-
next.style.display = "";
589-
} else {
590-
next.style.display = "none";
591-
}
592-
next = next.nextElementSibling;
585+
function isSignificant(variant) {
586+
const percent = Math.abs(variant.percent);
587+
if (variant.isDodgy) {
588+
return percent > 1.0;
589+
} else {
590+
return percent > 0.2;
593591
}
592+
594593
}
595594

596595
function toggleFilters(id, toggle) {

0 commit comments

Comments
 (0)