@@ -110,6 +110,13 @@ for (const [suite, benchmarks] of Object.entries(tests)) {
110
110
console . groupEnd ( ) ;
111
111
}
112
112
113
+ const metricInfoFilterByName =
114
+ ( testName : string ) =>
115
+ ( { info : { test_name } } : MetricInfo ) =>
116
+ test_name === testName ;
117
+
118
+ const isMBsMetric = ( { name } : Metric ) => name === 'megabytes_per_second' ;
119
+
113
120
function calculateCompositeBenchmarks ( results : MetricInfo [ ] ) {
114
121
const composites = {
115
122
singleBench : [ 'findOne' , 'smallDocInsertOne' , 'largeDocInsertOne' ] ,
@@ -144,13 +151,6 @@ function calculateCompositeBenchmarks(results: MetricInfo[]) {
144
151
]
145
152
} ;
146
153
147
- const aMetricInfo =
148
- ( testName : string ) =>
149
- ( { info : { test_name } } : MetricInfo ) =>
150
- test_name === testName ;
151
-
152
- const anMBsMetric = ( { name } : Metric ) => name === 'megabytes_per_second' ;
153
-
154
154
let readBenchResult ;
155
155
let writeBenchResult ;
156
156
@@ -162,10 +162,10 @@ function calculateCompositeBenchmarks(results: MetricInfo[]) {
162
162
163
163
let sum = 0 ;
164
164
for ( const testName of compositeTests ) {
165
- const testScore = results . find ( aMetricInfo ( testName ) ) ;
165
+ const testScore = results . find ( metricInfoFilterByName ( testName ) ) ;
166
166
assert . ok ( testScore , `${ compositeName } suite requires ${ testName } for composite score` ) ;
167
167
168
- const metric = testScore . metrics . find ( anMBsMetric ) ;
168
+ const metric = testScore . metrics . find ( isMBsMetric ) ;
169
169
assert . ok ( metric , `${ testName } is missing a megabytes_per_second metric` ) ;
170
170
171
171
sum += metric . value ;
@@ -199,31 +199,40 @@ function calculateCompositeBenchmarks(results: MetricInfo[]) {
199
199
}
200
200
201
201
function calculateNormalizedResults ( results : MetricInfo [ ] ) : MetricInfo [ ] {
202
- const baselineBench = results . find ( r => r . info . test_name === 'cpuBaseline' ) ;
203
- const pingBench = results . find ( r => r . info . test_name === 'ping' ) ;
202
+ const baselineBench = results . find ( metricInfoFilterByName ( 'cpuBaseline' ) ) ;
203
+ const pingBench = results . find ( metricInfoFilterByName ( 'ping' ) ) ;
204
204
205
205
assert . ok ( pingBench , 'ping bench results not found!' ) ;
206
- assert . ok ( baselineBench , 'baseline results not found!' ) ;
207
- const pingThroughput = pingBench . metrics [ 0 ] . value ;
208
- const cpuBaseline = baselineBench . metrics [ 0 ] . value ;
206
+ assert . ok ( baselineBench , 'cpuBaseline results not found!' ) ;
207
+
208
+ const cpuBaseline = baselineBench . metrics . find ( isMBsMetric ) ;
209
+ const pingThroughput = pingBench . metrics . find ( isMBsMetric ) ;
210
+
211
+ assert . ok ( cpuBaseline , 'cpu benchmark does not have a MB/s metric' ) ;
212
+ assert . ok ( pingThroughput , 'ping does not have a MB/s metric' ) ;
209
213
210
214
for ( const bench of results ) {
211
215
if ( bench . info . test_name === 'cpuBaseline' ) continue ;
216
+
217
+ const currentMetric = bench . metrics . find ( isMBsMetric ) ;
218
+ assert . ok ( currentMetric , `${ bench . info . test_name } does not have a MB/s metric` ) ;
219
+
212
220
if ( bench . info . test_name === 'ping' ) {
213
221
bench . metrics . push ( {
214
222
name : 'normalized_throughput' ,
215
- value : bench . metrics [ 0 ] . value / cpuBaseline ,
223
+ value : currentMetric . value / cpuBaseline . value ,
216
224
metadata : {
225
+ tags : currentMetric . metadata . tags ,
217
226
improvement_direction : 'up'
218
227
}
219
228
} ) ;
220
- }
221
- // Compute normalized_throughput of benchmarks against ping bench
222
- else {
229
+ } else {
230
+ // Compute normalized_throughput of benchmarks against ping bench
223
231
bench . metrics . push ( {
224
232
name : 'normalized_throughput' ,
225
- value : bench . metrics [ 0 ] . value / pingThroughput ,
233
+ value : currentMetric . value / pingThroughput . value ,
226
234
metadata : {
235
+ tags : currentMetric . metadata . tags ,
227
236
improvement_direction : 'up'
228
237
}
229
238
} ) ;
0 commit comments