@@ -201,22 +201,33 @@ function calculateCompositeBenchmarks(results: MetricInfo[]) {
201201function calculateNormalizedResults ( results : MetricInfo [ ] ) : MetricInfo [ ] {
202202 const primesBench = results . find ( r => r . info . test_name === 'primes' ) ;
203203 const pingBench = results . find ( r => r . info . test_name === 'ping' ) ;
204- let pingMegabytesPerSecond : number ;
205204
206205 if ( pingBench ) {
206+ const newMetrics : MetricInfo [ ] = [ ] ;
207207 const pingThroughput = pingBench . metrics [ 0 ] . value ;
208208 for ( const bench of results ) {
209- if ( bench . info . test_name === 'primes' || bench . info . test_name === 'ping' ) continue ;
210- const normalizedThroughput = bench . metrics [ 0 ] . value / pingThroughput ;
211- bench . metrics . push ( { name : 'normalized_throughput' , value : normalizedThroughput } ) ;
212-
209+ if ( bench . info . test_name === 'primes' ) {
210+ newMetrics . push ( { ...bench } ) ;
211+ }
212+ else if ( bench . info . test_name === 'ping' ) {
213+ // Compute ping's normalized_throughput against the primes bench if present
214+ if ( primesBench ) {
215+ const primesThroughput = primesBench . metrics [ 0 ] . value ;
216+ const normalizedThroughput : Metric = { 'name' : 'normalized_throughput' , value : bench . metrics [ 0 ] . value / primesThroughput } ;
217+ const newInfo : MetricInfo = { info : { ...bench . info } , metrics : [ ...bench . metrics , normalizedThroughput ] } ;
218+ newMetrics . push ( newInfo ) ;
219+ } else {
220+ newMetrics . push ( { ...bench } ) ;
221+ }
222+ } else {
223+ // Compute normalized_throughput of benchmarks against ping bench
224+ const normalizedThroughput : Metric = { 'name' : 'normalized_throughput' , value : bench . metrics [ 0 ] . value / pingThroughput } ;
225+ const newInfo : MetricInfo = { info : { ...bench . info } , metrics : [ ...bench . metrics , normalizedThroughput ] }
226+ newMetrics . push ( newInfo ) ;
227+ }
213228 }
214229
215- if ( primesBench ) {
216- const normalizedThroughput = pingBench . metrics [ 0 ] . value / primesBench . metrics [ 0 ] . value ;
217- pingMegabytesPerSecond = pingBench . metrics [ 0 ] . value ;
218- pingBench . metrics . push ( { name : 'normalized_throughput' , value : normalizedThroughput } ) ;
219- }
230+ return newMetrics ;
220231 }
221232
222233 return results ;
0 commit comments