Skip to content

Instantly share code, notes, and snippets.

@CompuIves
Created December 16, 2017 15:22
Show Gist options
  • Save CompuIves/de421c8a81df791fd225303746fdd47f to your computer and use it in GitHub Desktop.
Save CompuIves/de421c8a81df791fd225303746fdd47f to your computer and use it in GitHub Desktop.
const puppeteer = require('puppeteer');
let browser = puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox'],
});
async function test(url) {
browser = await browser;
const page = await browser.newPage();
const a = Date.now();
await page.goto(url, {
timeout: 60000,
});
await page.waitForSelector('#root', { timeout: 10000 });
console.log(Date.now() - a);
return Date.now() - a;
}
(async function go() {
const results = [];
for (let i = 0; i < 10; i++) {
const res = await test('https://new.codesandbox.io');
results.push(res);
}
browser.close();
const total = results.reduce((p, n) => p + n, 0);
const avg = total / results.length;
console.log('AVG: ' + avg);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment