1
- import { Benchmark , BenchmarkType , convertToMap , DisplayMode , Framework , FrameworkType , RawResult , Result , ResultTableData , SORT_BY_GEOMMEAN_CPU , categories } from "./Common"
1
+ import { Benchmark , BenchmarkType , convertToMap , DisplayMode , Framework , FrameworkType , RawResult , Result , ResultTableData , SORT_BY_GEOMMEAN_CPU , categories , Severity } from "./Common"
2
2
import { benchmarks as benchmark_orig , frameworks , results as rawResults } from './results' ;
3
3
4
4
// Temporarily disable script bootup time
@@ -18,7 +18,7 @@ const removeKeyedSuffix = (value: string) => {
18
18
else if ( value . endsWith ( '-keyed' ) ) return value . substring ( 0 , value . length - 6 )
19
19
return value ;
20
20
}
21
- const mappedFrameworks = frameworks . map ( f => ( { name : f . name , displayname : removeKeyedSuffix ( f . name ) , issues : f . issues ?? [ ] , type :f . keyed ? FrameworkType . KEYED : FrameworkType . NON_KEYED } ) ) ;
21
+ const mappedFrameworks = frameworks . map ( f => ( { name : f . name , dir : f . dir , displayname : removeKeyedSuffix ( f . name ) , issues : f . issues ?? [ ] , type :f . keyed ? FrameworkType . KEYED : FrameworkType . NON_KEYED } ) ) ;
22
22
23
23
const allBenchmarks = benchmarks . reduce ( ( set , b ) => set . add ( b ) , new Set < Benchmark > ( ) ) ;
24
24
const allFrameworks = mappedFrameworks . reduce ( ( set , f ) => set . add ( f ) , new Set < Framework > ( ) ) ;
@@ -84,7 +84,7 @@ const preInitialState: State = {
84
84
[ FrameworkType . KEYED ] : undefined ,
85
85
[ FrameworkType . NON_KEYED ] : undefined
86
86
} ,
87
- categories : new Set ( [ 1 , 2 , 3 , 4 ] )
87
+ categories : new Set ( categories . filter ( c => c . severity != Severity . Error ) . map ( c => c . id ) )
88
88
}
89
89
90
90
function updateResultTable ( { frameworks, benchmarks, selectedFrameworksDropDown : selectedFrameworks , selectedBenchmarks, sortKey, displayMode, compareWith, categories} : State ) {
@@ -147,14 +147,55 @@ interface SortAction { type: 'SORT'; data: {sortKey: string}}
147
147
export const sort = ( sortKey : string ) : SortAction => {
148
148
return { type : 'SORT' , data : { sortKey} }
149
149
}
150
+
151
+ interface SetStateFromClipboardAction { type : 'SET_STATE_FROM_CLIPBOARD' ; data : any }
152
+ export const setStateFromClipboard = ( state : any ) : SetStateFromClipboardAction => {
153
+ return { type : 'SET_STATE_FROM_CLIPBOARD' , data : { state} }
154
+ }
155
+
150
156
type Action = SelectFrameworkAction | SelectAllFrameworksAction | SelectBenchmarkAction | SelectAllBenchmarksAction
151
157
| SelectDisplayModeAction | CompareAction | StopCompareAction | SortAction
152
- | SelectCategoryAction | SelectAllCategoriesAction ;
158
+ | SelectCategoryAction | SelectAllCategoriesAction | SetStateFromClipboardAction ;
153
159
154
160
// eslint-disable-next-line @typescript-eslint/no-explicit-any
155
161
export const reducer = ( state = initialState , action : Action ) : State => {
156
162
console . log ( "reducer" , action )
157
163
switch ( action . type ) {
164
+ case 'SET_STATE_FROM_CLIPBOARD' : {
165
+ let t = { ...state } ;
166
+ debugger ;
167
+ if ( action . data . state ?. benchmarks ) {
168
+ const newSelectedBenchmarks = new Set < Benchmark > ( ) ;
169
+ for ( const b of action . data . state . benchmarks ) {
170
+ for ( const sb of benchmarks ) {
171
+ if ( b === sb . id ) newSelectedBenchmarks . add ( sb ) ;
172
+ }
173
+ }
174
+ t = { ...t , selectedBenchmarks : newSelectedBenchmarks } ;
175
+ }
176
+ if ( action . data . state ?. frameworks ) {
177
+ const newSelectedFramework = new Set < Framework > ( ) ;
178
+ for ( const f of action . data . state . frameworks ) {
179
+ for ( const sf of mappedFrameworks ) {
180
+ if ( f === sf . dir ) newSelectedFramework . add ( sf ) ;
181
+ }
182
+ }
183
+ t = { ...t , selectedFrameworksDropDown : newSelectedFramework } ;
184
+ }
185
+ if ( action . data . state ?. displayMode ) {
186
+ t = { ...t , displayMode : action . data . state . displayMode } ;
187
+ }
188
+ if ( action . data . state ?. categories ) {
189
+ const newSelectedCategories = new Set < number > ( ) ;
190
+ for ( const f of action . data . state ?. categories ) {
191
+ for ( const sc of categories ) {
192
+ if ( f === sc . id ) newSelectedCategories . add ( sc . id ) ;
193
+ }
194
+ }
195
+ t = { ...t , categories : newSelectedCategories } ;
196
+ }
197
+ return { ...t , resultTables : updateResultTable ( t ) }
198
+ }
158
199
case 'SELECT_FRAMEWORK' : {
159
200
const newSelectedFramework = new Set ( state . selectedFrameworksDropDown ) ;
160
201
if ( action . data . add ) newSelectedFramework . add ( action . data . framework ) ;
0 commit comments