File tree Expand file tree Collapse file tree 3 files changed +25
-9
lines changed
site/frontend/src/pages/compare Expand file tree Collapse file tree 3 files changed +25
-9
lines changed Original file line number Diff line number Diff line change 1
1
import { BenchmarkFilter , CompareResponse , StatComparison } from "../types" ;
2
2
import { calculateComparison , TestCaseComparison } from "../data" ;
3
+ import { benchmarkNameMatchesFilter } from "../shared" ;
3
4
4
5
export type CompileBenchmarkFilter = {
5
6
profile : {
@@ -158,17 +159,13 @@ export function computeCompileComparisonsWithNonRelevant(
158
159
}
159
160
160
161
function shouldShowTestCase ( comparison : TestCaseComparison < CompileTestCase > ) {
161
- const name = `${ comparison . testCase . benchmark } ${ comparison . testCase . profile } ${ comparison . testCase . scenario } ${ comparison . testCase . backend } ` ;
162
- const nameFilter = filter . name && filter . name . trim ( ) ;
163
- const nameFiltered = ! nameFilter || name . includes ( nameFilter ) ;
164
-
165
162
return (
166
163
profileFilter ( comparison . testCase . profile ) &&
167
164
scenarioFilter ( comparison . testCase . scenario ) &&
168
165
backendFilter ( comparison . testCase . backend ) &&
169
166
categoryFilter ( comparison . testCase . category ) &&
170
167
artifactFilter ( benchmarkMap [ comparison . testCase . benchmark ] ?? null ) &&
171
- nameFiltered
168
+ benchmarkNameMatchesFilter ( comparison . testCase . benchmark , filter . name )
172
169
) ;
173
170
}
174
171
Original file line number Diff line number Diff line change 1
1
import { BenchmarkFilter , StatComparison } from "../types" ;
2
2
import { calculateComparison , TestCaseComparison } from "../data" ;
3
+ import { benchmarkNameMatchesFilter } from "../shared" ;
3
4
4
5
export interface RuntimeTestCase {
5
6
benchmark : string ;
@@ -22,10 +23,13 @@ export function computeRuntimeComparisonsWithNonRelevant(
22
23
filter : RuntimeBenchmarkFilter ,
23
24
comparisons : RuntimeBenchmarkComparison [ ]
24
25
) : TestCaseComparison < RuntimeTestCase > [ ] {
25
- function shouldShowTestCase ( comparison : TestCaseComparison < RuntimeTestCase > ) {
26
- const name = comparison . testCase . benchmark ;
27
- const nameFilter = filter . name && filter . name . trim ( ) ;
28
- return ! nameFilter || name . includes ( nameFilter ) ;
26
+ function shouldShowTestCase (
27
+ comparison : TestCaseComparison < RuntimeTestCase >
28
+ ) : boolean {
29
+ return benchmarkNameMatchesFilter (
30
+ comparison . testCase . benchmark ,
31
+ filter . name
32
+ ) ;
29
33
}
30
34
31
35
let filteredComparisons = comparisons
Original file line number Diff line number Diff line change @@ -78,3 +78,18 @@ export function getBoolOrDefault(
78
78
}
79
79
return defaultValue ;
80
80
}
81
+
82
+ export function benchmarkNameMatchesFilter (
83
+ benchmarkName : string ,
84
+ filterName : string | null
85
+ ) : boolean {
86
+ if ( ! filterName ) return true ;
87
+ const trimmedFilterName = filterName . trim ( ) ;
88
+ // Use `includes()` when a regex is not valid.
89
+ try {
90
+ const filterRegex = new RegExp ( trimmedFilterName ) ;
91
+ return filterRegex . test ( benchmarkName ) ;
92
+ } catch ( e ) {
93
+ return benchmarkName . includes ( trimmedFilterName ) ;
94
+ }
95
+ }
You can’t perform that action at this time.
0 commit comments