我正在试验Puppeteer使用无头Chrome并试图找到如何报告第一次涂漆的时间.我一直在浏览 Chrome DevTools Performance API,并注意到有一个Performance.metrics,但是当我订阅该事件时,它从未触发过. con
          const client = page._client
await client.send('Page.enable')
await client.send('DOM.enable')
await client.send('Performance.enable')
client.on('Performance.metrics', (obj) => {
   console.log({obj})
})
await page.goto('http://example.com', {waitUntil: 'networkidle2'}) 
 但事件观察员从未被解雇过.关于如何从Performance中观察指标数据的任何建议?
如果您询问 First Meaningful Paint,可以使用以下方法获取:await page.goto('http://example');
await page.waitFor(1000);
const performanceMetrics = await page._client.send('Performance.getMetrics'); 
console.log(performanceMetrics); 
 我写了一篇文章“Test website performance with Puppeteer”,其中有一章专门用于测量FirstMeaningfulPaint.
