@@ -60,16 +60,18 @@ async function runCPUBenchmark(
60
60
61
61
console . log ( "benchmarking" , framework , benchmark . benchmarkInfo . id ) ;
62
62
let browser : Browser = null ;
63
- let page : Page = null ;
63
+ // let page: Page = null;
64
64
try {
65
65
browser = await startBrowser ( benchmarkOptions ) ;
66
- page = await browser . newPage ( ) ;
66
+ // page = await browser.newPage();
67
67
// if (config.LOG_DETAILS) {
68
- page . on ( "console" , ( msg ) => {
69
- for ( let i = 0 ; i < msg . args ( ) . length ; ++ i ) console . log ( `BROWSER: ${ msg . args ( ) [ i ] } ` ) ;
70
- } ) ;
68
+ // page.on("console", (msg) => {
69
+ // for (let i = 0; i < msg.args().length; ++i) console.log(`BROWSER: ${msg.args()[i]}`);
70
+ // });
71
71
// }
72
72
for ( let i = 0 ; i < benchmarkOptions . batchSize ; i ++ ) {
73
+ const page = await browser . newPage ( ) ;
74
+ page . on ( "console" , ( msg ) => console . log ( 'BROWSER:' , ...msg . args ( ) ) ) ;
73
75
try {
74
76
await page . goto ( `http://${ benchmarkOptions . host } :${ benchmarkOptions . port } /${ framework . uri } /index.html` , {
75
77
waitUntil : "networkidle0" ,
@@ -120,12 +122,13 @@ async function runCPUBenchmark(
120
122
screenshots : false ,
121
123
categories : categories ,
122
124
} ) ;
125
+ await wait ( 50 ) ;
123
126
await forceGC ( page , client ) ;
124
127
console . log ( "runBenchmark" ) ;
125
128
let m1 = await page . metrics ( ) ;
126
129
await runBenchmark ( page , benchmark , framework ) ;
127
130
128
- await wait ( 40 ) ;
131
+ await wait ( 50 ) ;
129
132
await page . tracing . stop ( ) ;
130
133
let m2 = await page . metrics ( ) ;
131
134
if ( throttleCPU ) {
@@ -142,6 +145,7 @@ async function runCPUBenchmark(
142
145
) ;
143
146
console . log ( "**** resultScript =" , resultScript ) ;
144
147
if ( m2 . Timestamp == m1 . Timestamp ) throw new Error ( "Page metrics timestamp didn't change" ) ;
148
+ await page . close ( ) ;
145
149
results . push ( { total : result . duration , script : resultScript } ) ;
146
150
console . log ( `duration for ${ framework . name } and ${ benchmark . benchmarkInfo . id } : ${ JSON . stringify ( result ) } ` ) ;
147
151
if ( result . duration < 0 ) throw new Error ( `duration ${ result } < 0` ) ;
0 commit comments