-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsimple_metrics.js
More file actions
28 lines (22 loc) · 811 Bytes
/
simple_metrics.js
File metadata and controls
28 lines (22 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const puppeteer = require("puppeteer");
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setCacheEnabled(false);
const client = await page.target().createCDPSession();
await client.send("Performance.enable");
await page.goto("https://ryanharrison.co.uk", {
waitUntil: "networkidle0"
});
const before = new Date().getTime();
await page.goto("https://ryanharrison.co.uk", {
waitUntil: "networkidle0"
});
const after = new Date().getTime();
const timing = JSON.parse(
await page.evaluate(() => JSON.stringify(window.performance.timing))
);
console.log(timing.loadEventEnd - timing.navigationStart);
console.log(after - before - 500);
await browser.close();
})();