@@ -50,9 +50,9 @@ function convertError(error: any): string {
50
50
}
51
51
52
52
// eslint-disable-next-line @typescript-eslint/no-unused-vars
53
- async function forceGC ( page : Page ) {
53
+ async function forceGC ( page : Page , client : CDPSession ) {
54
54
for ( let i = 0 ; i < 7 ; i ++ ) {
55
- // await client.send(' HeapProfiler.collectGarbage' );
55
+ await client . send ( " HeapProfiler.collectGarbage" ) ;
56
56
await page . evaluate ( "window.gc()" ) ;
57
57
}
58
58
}
@@ -111,6 +111,7 @@ async function runCPUBenchmark(
111
111
"devtools.timeline" ,
112
112
"disabled-by-default-devtools.timeline" ,
113
113
] ;
114
+ const client = await page . createCDPSession ( ) ;
114
115
115
116
// let categories = [
116
117
// "-*", // exclude default
@@ -142,7 +143,7 @@ async function runCPUBenchmark(
142
143
await wait ( 50 ) ;
143
144
await puppeteerWait ( ) ;
144
145
145
- await forceGC ( page ) ;
146
+ await forceGC ( page , client ) ;
146
147
await puppeteerWait ( ) ;
147
148
148
149
console . log ( "runBenchmark" ) ;
@@ -251,11 +252,11 @@ async function runMemBenchmark(
251
252
// });
252
253
console . log ( "initBenchmark" ) ;
253
254
await initBenchmark ( page , benchmark , framework ) ;
254
- const client = await page . target ( ) . createCDPSession ( ) ;
255
+ const client = await page . createCDPSession ( ) ;
255
256
256
257
console . log ( "runBenchmark" ) ;
257
258
await runBenchmark ( page , benchmark , framework ) ;
258
- await forceGC ( page ) ;
259
+ await forceGC ( page , client ) ;
259
260
await wait ( 40 ) ;
260
261
let result = ( ( await page . evaluate ( "performance.measureUserAgentSpecificMemory()" ) ) as any ) . bytes / 1024 / 1024 ;
261
262
console . log ( "afterBenchmark" ) ;
0 commit comments