Skip to content

Commit 3f19d77

Browse files
authored
Merge pull request #1041 from rylev/fix-filtering
Fix broken filtering code
2 parents 3e0f7d5 + 8cbe886 commit 3f19d77

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

site/static/compare.html

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,9 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
571571
}
572572
}
573573

574-
function shouldShowTestCase(testCase) {
574+
function shouldShowTestCase(name, testCase) {
575575
let nameFilter = filter.name && filter.name.trim();
576-
nameFilter = !nameFilter || (testCase.benchmark + "-" + testCase.profile).includes(nameFilter);
576+
nameFilter = !nameFilter || name.includes(nameFilter);
577577

578578
const significanceFilter = filter.showOnlySignificant ? testCase.isSignificant : true;
579579

@@ -582,17 +582,16 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
582582
return scenarioFilter(testCase.scenario) && significanceFilter && nameFilter && magnitudeFilter;
583583
}
584584

585-
function toTestCases(results) {
586-
let testCases = [];
587-
for (let r of results) {
585+
function toTestCases(name, results) {
586+
return results.map(r => {
588587
const scenario = r.scenario;
589588
const datumA = r.statistics[0];
590589
const datumB = r.statistics[1];
591590
const isSignificant = r.is_significant;
592591
const significanceFactor = r.significance_factor;
593592
const isDodgy = r.is_dodgy;
594593
let percent = 100 * ((datumB - datumA) / datumA);
595-
let testCase = {
594+
return {
596595
scenario,
597596
datumA,
598597
datumB,
@@ -602,12 +601,7 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
602601
isDodgy,
603602
percent,
604603
};
605-
if (shouldShowTestCase(testCase)) {
606-
testCases.push(testCase);
607-
}
608-
}
609-
610-
return testCases;
604+
}).filter(tc => shouldShowTestCase(name, tc))
611605
}
612606

613607
let benches =
@@ -624,7 +618,7 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
624618
map(c => {
625619
const name = c[0];
626620
const comparison = c[1];
627-
const testCases = toTestCases(comparison);
621+
const testCases = toTestCases(name, comparison);
628622
const pcts = testCases.map(tc => parseFloat(tc.percent));
629623
const maxPct = Math.max(...pcts).toFixed(1);
630624
const minPct = Math.min(...pcts).toFixed(1);

0 commit comments

Comments
 (0)