@@ -110,6 +110,13 @@ for (const [suite, benchmarks] of Object.entries(tests)) {
110110 console . groupEnd ( ) ;
111111}
112112
113+ const aMetricInfo =
114+ ( testName : string ) =>
115+ ( { info : { test_name } } : MetricInfo ) =>
116+ test_name === testName ;
117+
118+ const anMBsMetric = ( { name } : Metric ) => name === 'megabytes_per_second' ;
119+
113120function calculateCompositeBenchmarks ( results : MetricInfo [ ] ) {
114121 const composites = {
115122 singleBench : [ 'findOne' , 'smallDocInsertOne' , 'largeDocInsertOne' ] ,
@@ -144,13 +151,6 @@ function calculateCompositeBenchmarks(results: MetricInfo[]) {
144151 ]
145152 } ;
146153
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-
154154 let readBenchResult ;
155155 let writeBenchResult ;
156156
@@ -199,31 +199,40 @@ function calculateCompositeBenchmarks(results: MetricInfo[]) {
199199}
200200
201201function 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 ( aMetricInfo ( 'cpuBaseline' ) ) ;
203+ const pingBench = results . find ( aMetricInfo ( 'ping' ) ) ;
204204
205205 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 ( anMBsMetric ) ;
209+ const pingThroughput = pingBench . metrics . find ( anMBsMetric ) ;
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' ) ;
209213
210214 for ( const bench of results ) {
211215 if ( bench . info . test_name === 'cpuBaseline' ) continue ;
216+
217+ const currentMetric = bench . metrics . find ( anMBsMetric ) ;
218+ assert . ok ( currentMetric , `${ bench . info . test_name } does not have a MB/s metric` ) ;
219+
212220 if ( bench . info . test_name === 'ping' ) {
213221 bench . metrics . push ( {
214222 name : 'normalized_throughput' ,
215- value : bench . metrics [ 0 ] . value / cpuBaseline ,
223+ value : currentMetric . value / cpuBaseline . value ,
216224 metadata : {
225+ tags : currentMetric . metadata . tags ,
217226 improvement_direction : 'up'
218227 }
219228 } ) ;
220- }
221- // Compute normalized_throughput of benchmarks against ping bench
222- else {
229+ } else {
230+ // Compute normalized_throughput of benchmarks against ping bench
223231 bench . metrics . push ( {
224232 name : 'normalized_throughput' ,
225- value : bench . metrics [ 0 ] . value / pingThroughput ,
233+ value : currentMetric . value / pingThroughput . value ,
226234 metadata : {
235+ tags : currentMetric . metadata . tags ,
227236 improvement_direction : 'up'
228237 }
229238 } ) ;
0 commit comments