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 11import { BenchmarkFilter , CompareResponse , StatComparison } from "../types" ;
22import { calculateComparison , TestCaseComparison } from "../data" ;
3+ import { benchmarkNameMatchesFilter } from "../shared" ;
34
45export type CompileBenchmarkFilter = {
56 profile : {
@@ -158,17 +159,13 @@ export function computeCompileComparisonsWithNonRelevant(
158159 }
159160
160161 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-
165162 return (
166163 profileFilter ( comparison . testCase . profile ) &&
167164 scenarioFilter ( comparison . testCase . scenario ) &&
168165 backendFilter ( comparison . testCase . backend ) &&
169166 categoryFilter ( comparison . testCase . category ) &&
170167 artifactFilter ( benchmarkMap [ comparison . testCase . benchmark ] ?? null ) &&
171- nameFiltered
168+ benchmarkNameMatchesFilter ( comparison . testCase . benchmark , filter . name )
172169 ) ;
173170 }
174171
Original file line number Diff line number Diff line change 11import { BenchmarkFilter , StatComparison } from "../types" ;
22import { calculateComparison , TestCaseComparison } from "../data" ;
3+ import { benchmarkNameMatchesFilter } from "../shared" ;
34
45export interface RuntimeTestCase {
56 benchmark : string ;
@@ -22,10 +23,13 @@ export function computeRuntimeComparisonsWithNonRelevant(
2223 filter : RuntimeBenchmarkFilter ,
2324 comparisons : RuntimeBenchmarkComparison [ ]
2425) : 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+ ) ;
2933 }
3034
3135 let filteredComparisons = comparisons
Original file line number Diff line number Diff line change @@ -78,3 +78,18 @@ export function getBoolOrDefault(
7878 }
7979 return defaultValue ;
8080}
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