@@ -120,6 +120,7 @@ async function runPerformanceTest(opts: Opts): Promise<void> {
120120 Constants . RUNTIME ,
121121 '--prof-append-timers' ,
122122 Constants . PERF_FILE ,
123+ '--prof-append-heap-statistics' ,
123124 '--runs' ,
124125 '10'
125126 ]
@@ -189,13 +190,14 @@ async function runPerformanceTest(opts: Opts): Promise<void> {
189190type PerfData = {
190191 readonly commit : string ;
191192 readonly appName : string ;
193+
192194 readonly bestDuration : number ;
193195
194- readonly avgHeapAllocated : number | undefined ;
195- readonly avgHeapCollected : number | undefined ;
196- readonly avgMajorGC : number | undefined ;
197- readonly avgMinorGC : number | undefined ;
198- readonly avgGCDuration : number | undefined ;
196+ readonly bestHeapUsed : number | undefined ;
197+ readonly bestHeapGarbage : number | undefined ;
198+ readonly bestMajorGCs : number | undefined ;
199+ readonly bestMinorGCs : number | undefined ;
200+ readonly bestGCDuration : number | undefined ;
199201
200202 readonly lines : string [ ] ;
201203}
@@ -209,11 +211,11 @@ function parsePerfFile(): PerfData | undefined {
209211 let commitValue = 'unknown' ;
210212 let appNameValue = 'unknown' ;
211213 let bestDuration : number = Number . MAX_SAFE_INTEGER ;
212- let heapsAllocated : number [ ] = [ ] ;
213- let heapsCollected : number [ ] = [ ] ;
214- let majorGCs : number [ ] = [ ] ;
215- let minorGCs : number [ ] = [ ] ;
216- let gcDurations : number [ ] = [ ] ;
214+ let bestHeapUsed : number = 0 ;
215+ let bestHeapGarbage : number = 0 ;
216+ let bestMajorGCs : number = 0 ;
217+ let bestMinorGCs : number = 0 ;
218+ let bestGCDuration : number = 0 ;
217219 for ( const line of rawLines ) {
218220 if ( ! line ) {
219221 continue ;
@@ -226,17 +228,17 @@ function parsePerfFile(): PerfData | undefined {
226228 commitValue = commit ;
227229 if ( duration < bestDuration ) {
228230 bestDuration = duration ;
229- }
230231
231- if ( heap ) { // currently only supported for web
232- const res = / H e a p : ( \d + ) M B \( u s e d \) ( \d + ) M B \( g a r b a g e \) ( \d + ) \( M a j o r G C \) ( \d + ) \( M i n o r G C \) ( \d + ) m s \( G C d u r a t i o n \) / . exec ( heap ) ;
233- if ( res ) {
234- const [ , heapAllocated , heapCollected , majorGC , minorGC , gcDuration ] = res ;
235- heapsAllocated . push ( Number ( heapAllocated ) ) ;
236- heapsCollected . push ( Number ( heapCollected ) ) ;
237- majorGCs . push ( Number ( majorGC ) ) ;
238- minorGCs . push ( Number ( minorGC ) ) ;
239- gcDurations . push ( Number ( gcDuration ) ) ;
232+ if ( heap ) {
233+ const res = / H e a p : ( \d + ) M B \( u s e d \) ( \d + ) M B \( g a r b a g e \) ( \d + ) \( M a j o r G C \) ( \d + ) \( M i n o r G C \) ( \d + ) m s \( G C d u r a t i o n \) / . exec ( heap ) ;
234+ if ( res ) {
235+ const [ , used , garbage , majorGC , minorGC , gcDuration ] = res ;
236+ bestHeapUsed = Number ( used ) ;
237+ bestHeapGarbage = Number ( garbage ) ;
238+ bestMajorGCs = Number ( majorGC ) ;
239+ bestMinorGCs = Number ( minorGC ) ;
240+ bestGCDuration = Number ( gcDuration ) ;
241+ }
240242 }
241243 }
242244
@@ -252,12 +254,12 @@ function parsePerfFile(): PerfData | undefined {
252254 return {
253255 commit : commitValue ,
254256 appName : appNameValue ,
255- bestDuration : bestDuration ,
256- avgHeapAllocated : heapsAllocated . length ? Math . round ( heapsAllocated . reduce ( ( p , c ) => p + c , 0 ) / heapsAllocated . length ) : undefined ,
257- avgHeapCollected : heapsCollected . length ? Math . round ( heapsCollected . reduce ( ( p , c ) => p + c , 0 ) / heapsCollected . length ) : undefined ,
258- avgMajorGC : majorGCs . length ? Math . round ( majorGCs . reduce ( ( p , c ) => p + c , 0 ) / majorGCs . length ) : undefined ,
259- avgMinorGC : minorGCs . length ? Math . round ( minorGCs . reduce ( ( p , c ) => p + c , 0 ) / minorGCs . length ) : undefined ,
260- avgGCDuration : gcDurations . length ? Math . round ( gcDurations . reduce ( ( p , c ) => p + c , 0 ) / gcDurations . length ) : undefined ,
257+ bestDuration,
258+ bestHeapUsed ,
259+ bestHeapGarbage ,
260+ bestMajorGCs ,
261+ bestMinorGCs ,
262+ bestGCDuration ,
261263 lines
262264 }
263265}
@@ -279,7 +281,7 @@ async function sendSlackMessage(data: PerfData, opts: Opts): Promise<void> {
279281 }
280282 }
281283
282- const { commit, bestDuration, avgHeapAllocated , avgHeapCollected , avgMajorGC , avgMinorGC , avgGCDuration , lines } = data ;
284+ const { commit, bestDuration, bestHeapUsed , bestHeapGarbage , bestMajorGCs , bestMinorGCs , bestGCDuration , lines } = data ;
283285
284286 const slack = new WebClient ( opts . slackToken , { logLevel : LogLevel . ERROR } ) ;
285287
@@ -312,11 +314,11 @@ async function sendSlackMessage(data: PerfData, opts: Opts): Promise<void> {
312314 if ( opts . runtime === 'web' ) {
313315 summary += `, SCENARIO \`${ opts . githubToken ? 'standard remote' : 'empty window' } \`` ;
314316 }
315- if ( avgHeapAllocated && avgHeapCollected ) {
316- summary += `, HEAP \`${ avgHeapAllocated } MB (used) ${ avgHeapCollected } MB (garbage) ${ Math . round ( avgHeapCollected / avgHeapAllocated * 100 ) } % (ratio)\`` ;
317+ if ( bestHeapUsed && bestHeapGarbage ) {
318+ summary += `, HEAP \`${ bestHeapUsed } MB (used) ${ bestHeapGarbage } MB (garbage) ${ Math . round ( bestHeapGarbage / bestHeapUsed * 100 ) } % (ratio)\`` ;
317319 }
318- if ( avgMajorGC && avgMinorGC && avgGCDuration ) {
319- summary += `, GC \`${ avgMajorGC } (MajorGC) ${ avgMinorGC } (MinorGC) ${ avgGCDuration } ms (duration)\`` ;
320+ if ( bestMajorGCs && bestMinorGCs && bestGCDuration ) {
321+ summary += `, GC \`${ bestMajorGCs } (MajorGC) ${ bestMinorGCs } (MinorGC) ${ bestGCDuration } ms (duration)\`` ;
320322 }
321323
322324 const detail = `\`\`\`${ lines . join ( '\n' ) } \`\`\`` ;
0 commit comments