Skip to content

Commit 89ea753

Browse files
committed
Add benchmark
1 parent c6294aa commit 89ea753

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

sandbox-performance-benchmark.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const puppeteer = require('puppeteer');
2+
3+
function pageLoaded(page) {
4+
return new Promise(async resolve => {
5+
await page.exposeFunction('__puppeteer__', () => {
6+
if (resolve) {
7+
resolve();
8+
}
9+
});
10+
});
11+
}
12+
13+
let browser = puppeteer.launch();
14+
const SANDBOX_ID = process.argv[2];
15+
const results = [];
16+
17+
(async function() {
18+
browser = await browser;
19+
console.log('Testing speed of ' + SANDBOX_ID);
20+
21+
for (let i = 0; i < (process.argv[3] || 10); i++) {
22+
const page = await browser.newPage();
23+
const waitFunction = pageLoaded(page);
24+
25+
page.goto('http://localhost:3002/#' + SANDBOX_ID);
26+
const a = Date.now();
27+
await waitFunction;
28+
const d = Date.now() - a;
29+
results.push(d);
30+
console.log('Run #' + i + ': ' + d);
31+
page.close();
32+
}
33+
34+
console.log('Results', results.reduce((p, n) => p + n, 0) / results.length);
35+
})();

0 commit comments

Comments
 (0)