@@ -2,8 +2,8 @@ import { promises as fs } from 'fs';
22import path from 'path' ;
33import { mean as calculateMean } from 'lodash' ;
44import {
5- BenchmarkMetrics ,
65 BenchmarkSummary ,
6+ NumericBenchmarkMetrics ,
77} from '../test/e2e/page-objects/benchmark/page-load-benchmark' ;
88
99/**
@@ -101,12 +101,12 @@ function aggregateHistoricalBenchmarkData(
101101 const pageData : BenchmarkSummary = {
102102 page : pageName ,
103103 samples : 0 , // Not used downstream
104- mean : { } as BenchmarkMetrics ,
105- standardDeviation : { } as BenchmarkMetrics ,
106- min : { } as BenchmarkMetrics ,
107- max : { } as BenchmarkMetrics ,
108- p95 : { } as BenchmarkMetrics ,
109- p99 : { } as BenchmarkMetrics ,
104+ mean : { } ,
105+ standardDeviation : { } ,
106+ min : { } ,
107+ max : { } ,
108+ p95 : { } ,
109+ p99 : { } ,
110110 } ;
111111
112112 // Collect mean values for key metrics across all commits
@@ -120,9 +120,7 @@ function aggregateHistoricalBenchmarkData(
120120 // Only collect key metrics
121121 Object . values ( KeyMetrics ) . forEach ( ( metricKey ) => {
122122 const metricValue =
123- pageSummary . mean [
124- metricKey as keyof Omit < BenchmarkMetrics , 'memoryUsage' >
125- ] ;
123+ pageSummary . mean [ metricKey as keyof NumericBenchmarkMetrics ] ;
126124 if ( typeof metricValue === 'number' ) {
127125 if ( ! metricMeans [ metricKey ] ) {
128126 metricMeans [ metricKey ] = [ ] ;
@@ -139,7 +137,7 @@ function aggregateHistoricalBenchmarkData(
139137 if ( values . length > 0 ) {
140138 const calculatedMean = calculateMean ( values ) ;
141139 pageData . mean [
142- metricKey as keyof Omit < BenchmarkMetrics , 'memoryUsage' >
140+ metricKey as keyof NumericBenchmarkMetrics
143141 ] = calculatedMean ;
144142 }
145143 } ) ;
@@ -337,10 +335,10 @@ function getMetricValues(
337335 metric : string ,
338336) : { mean : number ; stdDev : number } | null {
339337 const meanValue =
340- summary . mean [ metric as keyof Omit < BenchmarkMetrics , 'memoryUsage' > ] ;
338+ summary . mean [ metric as keyof NumericBenchmarkMetrics ] ;
341339 const stdDevValue =
342340 summary . standardDeviation [
343- metric as keyof Omit < BenchmarkMetrics , 'memoryUsage' >
341+ metric as keyof NumericBenchmarkMetrics
344342 ] ;
345343
346344 if ( typeof meanValue !== 'number' ) {
@@ -486,13 +484,13 @@ function generateBenchmarkComment(
486484 }
487485
488486 const minValue =
489- pageSummary . min [ metric as keyof Omit < BenchmarkMetrics , 'memoryUsage' > ] ;
487+ pageSummary . min [ metric as keyof NumericBenchmarkMetrics ] ;
490488 const maxValue =
491- pageSummary . max [ metric as keyof Omit < BenchmarkMetrics , 'memoryUsage' > ] ;
489+ pageSummary . max [ metric as keyof NumericBenchmarkMetrics ] ;
492490 const p95Value =
493- pageSummary . p95 [ metric as keyof Omit < BenchmarkMetrics , 'memoryUsage' > ] ;
491+ pageSummary . p95 [ metric as keyof NumericBenchmarkMetrics ] ;
494492 const p99Value =
495- pageSummary . p99 [ metric as keyof Omit < BenchmarkMetrics , 'memoryUsage' > ] ;
493+ pageSummary . p99 [ metric as keyof NumericBenchmarkMetrics ] ;
496494
497495 comment += `| ${ metric } | ${ formatTime ( currentValues . mean ) } | ${ formatTime ( currentValues . stdDev ) } | ${ formatTime ( minValue || 0 ) } | ${ formatTime ( maxValue || 0 ) } | ${ formatTime ( p95Value || 0 ) } | ${ formatTime ( p99Value || 0 ) } |\n` ;
498496 }
0 commit comments