Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose CPU related metrics from page.metrics() as phantomas metrics #841

Merged
merged 4 commits into from
Dec 23, 2020

Conversation

gmetais
Copy link
Contributor

@gmetais gmetais commented Dec 22, 2020

This pull request adds 6 new metrics, taken from Puppeteer's page.metrics() values:

  • layoutCount: total number of full or partial page layout
  • layoutDuration: combined durations of all page layouts
  • recalcStyleCount: total number of page style recalculations
  • recalcStyleDuration: combined duration of all page style recalculations
  • scriptDuration: combined duration of JavaScript execution
  • taskDuration: combined duration of all tasks performed by the browser

The scriptDuration looks particularly important to me, as pages tend to have more and more JS on the web. More information here: https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagemetrics

Don't hesitate if you'd like me to change things such as metrics names, or if I forgot something.

(I can't add tests, as time-based values fluctuate too much. Count values are more stable, but they might also change with browser updates.)

@macbre macbre added this to the v2.1 milestone Dec 22, 2020
@macbre
Copy link
Owner

macbre commented Dec 23, 2020

@gmetais - thanks for yet another PR 🙂

@macbre macbre merged commit 133cca1 into macbre:devel Dec 23, 2020
return Math.round(value * 1000);
}

phantomas.on("metrics", (metrics) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope that one day we'd be able to use benefits of TypeScript here 🙂

#830

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants