@@ -85,7 +85,7 @@ console.log(systemInfo());
8585
8686const runnerPath = path . join ( __dirname , 'runner.mjs' ) ;
8787
88- const results : MetricInfo [ ] = [ ] ;
88+ let results : MetricInfo [ ] = [ ] ;
8989
9090for ( const [ suite , benchmarks ] of Object . entries ( tests ) ) {
9191 console . group ( snakeToCamel ( suite ) ) ;
@@ -146,8 +146,8 @@ function calculateCompositeBenchmarks(results: MetricInfo[]) {
146146
147147 const aMetricInfo =
148148 ( testName : string ) =>
149- ( { info : { test_name } } : MetricInfo ) =>
150- test_name === testName ;
149+ ( { info : { test_name } } : MetricInfo ) =>
150+ test_name === testName ;
151151
152152 const anMBsMetric = ( { name } : Metric ) => name === 'megabytes_per_second' ;
153153
@@ -198,6 +198,32 @@ function calculateCompositeBenchmarks(results: MetricInfo[]) {
198198 return [ ...results , ...compositeResults ] ;
199199}
200200
201- const finalResults = calculateCompositeBenchmarks ( results ) ;
201+ function calculateNormalizedResults ( results : MetricInfo [ ] ) : MetricInfo [ ] {
202+ const primesBench = results . find ( r => r . info . test_name === 'primes' ) ;
203+ const pingBench = results . find ( r => r . info . test_name === 'ping' ) ;
204+ let pingMegabytesPerSecond : number ;
202205
203- await fs . writeFile ( 'results.json' , JSON . stringify ( finalResults , undefined , 2 ) , 'utf8' ) ;
206+ if ( pingBench ) {
207+ const pingThroughput = pingBench . metrics [ 0 ] . value ;
208+ 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+
213+ }
214+
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+ }
220+ }
221+
222+ return results ;
223+ }
224+
225+ results = calculateNormalizedResults ( results ) ;
226+ results = calculateCompositeBenchmarks ( results ) ;
227+
228+
229+ await fs . writeFile ( 'results.json' , JSON . stringify ( results , undefined , 2 ) , 'utf8' ) ;
0 commit comments