1
- import { Benchmark , BenchmarkType , convertToMap , DisplayMode , Framework , FrameworkType , RawResult , Result , ResultTableData , SORT_BY_GEOMMEAN_CPU , categories , Severity } from "./Common"
1
+ import { Benchmark , BenchmarkType , convertToMap , DisplayMode , Framework , FrameworkType , RawResult , Result , ResultTableData , SORT_BY_GEOMMEAN_CPU , categories , Severity , ResultValues , CpuDurationMode } from "./Common"
2
2
import { benchmarks as benchmark_orig , frameworks , results as rawResults } from './results' ;
3
3
4
4
// Temporarily disable script bootup time
@@ -9,12 +9,20 @@ const benchmarks = benchmark_orig.filter(b => b.id !== '32_startup-bt'
9
9
// eslint-disable-next-line @typescript-eslint/no-var-requires
10
10
const jStat = require ( 'jstat' ) . jStat ;
11
11
12
- const results : Result [ ] = ( rawResults as RawResult [ ] ) . map ( res => Object . assign ( ( { framework : res . f , benchmark : res . b , values : res . v } ) ,
13
- {
14
- mean : res . v ? jStat . mean ( res . v ) : Number . NaN ,
15
- median : res . v ? jStat . median ( res . v ) : Number . NaN ,
16
- standardDeviation : res . v ? jStat . stdev ( res . v , true ) : Number . NaN
17
- } ) ) ;
12
+ const results : Result [ ] = ( rawResults as RawResult [ ] ) . map ( res => {
13
+ const values : { [ k : string ] : ResultValues } = { } ;
14
+ for ( const key of Object . keys ( res . v ) ) {
15
+ const r = res . v [ key ] ;
16
+ const vals = {
17
+ mean : r ? jStat . mean ( r ) : Number . NaN ,
18
+ median : r ? jStat . median ( r ) : Number . NaN ,
19
+ standardDeviation : r ? jStat . stdev ( r , true ) : Number . NaN ,
20
+ values : r
21
+ }
22
+ values [ key ] = vals ;
23
+ }
24
+ return { framework : res . f , benchmark : res . b , results : values }
25
+ } ) ;
18
26
19
27
const removeKeyedSuffix = ( value : string ) => {
20
28
if ( value . endsWith ( '-non-keyed' ) ) return value . substring ( 0 , value . length - 10 )
@@ -52,6 +60,7 @@ export interface State {
52
60
displayMode : DisplayMode ;
53
61
compareWith : CompareWith ;
54
62
categories : Set < number > ;
63
+ cpuDurationMode : CpuDurationMode ;
55
64
}
56
65
57
66
export const areAllBenchmarksSelected = ( state : State , type : BenchmarkType ) : boolean => state . benchmarkLists [ type ] . every ( b => state . selectedBenchmarks . has ( b ) )
@@ -87,13 +96,14 @@ let preInitialState: State = {
87
96
[ FrameworkType . KEYED ] : undefined ,
88
97
[ FrameworkType . NON_KEYED ] : undefined
89
98
} ,
90
- categories : new Set ( categories . filter ( c => c . severity != Severity . Error ) . map ( c => c . id ) )
99
+ categories : new Set ( categories . filter ( c => c . severity != Severity . Error ) . map ( c => c . id ) ) ,
100
+ cpuDurationMode : CpuDurationMode . Total
91
101
}
92
102
93
- function updateResultTable ( { frameworks, benchmarks, selectedFrameworksDropDown : selectedFrameworks , selectedBenchmarks, sortKey, displayMode, compareWith, categories } : State ) {
103
+ function updateResultTable ( { frameworks, benchmarks, selectedFrameworksDropDown : selectedFrameworks , selectedBenchmarks, sortKey, displayMode, compareWith, categories, cpuDurationMode } : State ) {
94
104
return {
95
- [ FrameworkType . KEYED ] : new ResultTableData ( frameworks , benchmarks , resultLookup , selectedFrameworks , selectedBenchmarks , FrameworkType . KEYED , sortKey , displayMode , compareWith [ FrameworkType . KEYED ] , categories ) ,
96
- [ FrameworkType . NON_KEYED ] : new ResultTableData ( frameworks , benchmarks , resultLookup , selectedFrameworks , selectedBenchmarks , FrameworkType . NON_KEYED , sortKey , displayMode , compareWith [ FrameworkType . NON_KEYED ] , categories )
105
+ [ FrameworkType . KEYED ] : new ResultTableData ( frameworks , benchmarks , resultLookup , selectedFrameworks , selectedBenchmarks , FrameworkType . KEYED , sortKey , displayMode , compareWith [ FrameworkType . KEYED ] , categories , cpuDurationMode ) ,
106
+ [ FrameworkType . NON_KEYED ] : new ResultTableData ( frameworks , benchmarks , resultLookup , selectedFrameworks , selectedBenchmarks , FrameworkType . NON_KEYED , sortKey , displayMode , compareWith [ FrameworkType . NON_KEYED ] , categories , cpuDurationMode )
97
107
}
98
108
}
99
109
@@ -123,7 +133,7 @@ function extractState(state: any): Partial<State> {
123
133
}
124
134
if ( state . categories !== undefined ) {
125
135
const newSelectedCategories = new Set < number > ( ) ;
126
- for ( const f of state ?. categories ) {
136
+ for ( const f of state ?. categories ?? [ ] ) {
127
137
for ( const sc of categories ) {
128
138
if ( f === sc . id ) newSelectedCategories . add ( sc . id ) ;
129
139
}
@@ -192,6 +202,10 @@ interface SelectDisplayModeAction { type: 'SELECT_DISPLAYMODE'; data: { displayM
192
202
export const selectDisplayMode = ( displayMode : DisplayMode ) : SelectDisplayModeAction => {
193
203
return { type : 'SELECT_DISPLAYMODE' , data : { displayMode } }
194
204
}
205
+ interface SelectCpuDurationModeAction { type : 'SELECT_CPUDURATIONMODE' ; data : { cpuDurationMode : CpuDurationMode } }
206
+ export const selectCpuDurationMode = ( cpuDurationMode : CpuDurationMode ) : SelectCpuDurationModeAction => {
207
+ return { type : 'SELECT_CPUDURATIONMODE' , data : { cpuDurationMode } }
208
+ }
195
209
196
210
interface CompareAction { type : 'COMPARE' ; data : { framework : Framework } }
197
211
export const compare = ( framework : Framework ) : CompareAction => {
@@ -217,7 +231,7 @@ export const setStateFromClipboard = (state: any): SetStateFromClipboardAction =
217
231
218
232
type Action = SelectFrameworkAction | SelectAllFrameworksAction | SelectBenchmarkAction | SelectAllBenchmarksAction
219
233
| SelectDisplayModeAction | CompareAction | StopCompareAction | SortAction
220
- | SelectCategoryAction | SelectAllCategoriesAction | SetStateFromClipboardAction ;
234
+ | SelectCategoryAction | SelectAllCategoriesAction | SetStateFromClipboardAction | SelectCpuDurationModeAction ;
221
235
222
236
export const reducer = ( state = initialState , action : Action ) : State => {
223
237
console . log ( "reducer" , action )
@@ -267,6 +281,10 @@ export const reducer = (state = initialState, action: Action): State => {
267
281
const t = { ...state , displayMode : action . data . displayMode } ;
268
282
return { ...t , resultTables : updateResultTable ( t ) } ;
269
283
}
284
+ case 'SELECT_CPUDURATIONMODE' : {
285
+ const t = { ...state , cpuDurationMode : action . data . cpuDurationMode } ;
286
+ return { ...t , resultTables : updateResultTable ( t ) } ;
287
+ }
270
288
case 'COMPARE' : {
271
289
const compareWith = { ...state . compareWith } ;
272
290
compareWith [ action . data . framework . type ] = action . data . framework ;
0 commit comments