To benchmark page loading times with Puppeteer, you can follow these steps:
npm install puppeteer
const puppeteer = require('puppeteer');
async function benchmarkPageLoadingTime(url) {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const startTime = new Date().getTime();
await page.goto(url, {waitUntil: 'networkidle2'});
const endTime = new Date().getTime();
console.log(`Page loading time for ${url}: ${endTime - startTime}ms`);
await browser.close();
}
benchmarkPageLoadingTime('https://www.example.com');
node benchmark.js
This will open a new Puppeteer browser, navigate to the specified URL, and measure the page loading time. The loading time will be printed out in the terminal. Repeat this process for any other pages you want to benchmark.