Skip to content

Instantly share code, notes, and snippets.

@addyosmani
Last active October 20, 2020 21:00
Show Gist options
  • Save addyosmani/45b135900a7e3296e22673148ae5165b to your computer and use it in GitHub Desktop.
Save addyosmani/45b135900a7e3296e22673148ae5165b to your computer and use it in GitHub Desktop.
V8 Runtime Call Stats and WebPageTest

V8 Runtime Call Stats and WebPageTest

V8's Runtime Call Stats provide precise timing information for all V8 components. This provides more granular information on where V8 spends its time than we've exposed in DevTools previously. Insights it offers includes time spent preparsing scripts, lazy compilation and so on.

This guide is a compliment to the 'Runtime Call Stats in Chrome' using about:tracing tutorial.

  1. Go to webpagetest.org. Expand the WebPageTest Advanced tab and go to 'Chrome'
  2. Check the 'Capture Dev Tools Timeline' and 'Capture Chrome Trace (about://tracing)' checkboxes
  3. In 'Trace Categories', replace the text with disabled-by-default-v8.runtime_stats
  4. Specify your Website URL, test location and browser. At the time of writing, it will need to be Chrome Canary.
  5. Click 'Start Test' and wait for your results to complete.
  6. The very left-hand-side of your 'Test Results' will include a column with First View and (depending on your settings) Repeat View. Here you can click on Timeline or Trace to download the trace file. Alternatively you can click view next to Trace to view Trace directly.
  7. If you downloaded your trace, you will probably have a .json file in Downloads (or whereever you saved it).
  8. Fire up Chrome Canary. Open up about:tracing.
  9. Click 'Load' and select the .json file
  10. Once loaded, you can go to the search-box next to 'View Options' and type in 'runtime' or 'runtime_stats'.
  11. You should now see a number of V8.RuntimeStats available. W00t. They look a little like this:

screen shot 2017-01-12 at 9 51 49 am

The run used for the above tutorial is available on WebPageTest here: https://www.webpagetest.org/result/170112_SW_4G96/

Note: V8 also offer a callstats.py helper for more easily aggregating statistics exposed by RCS should you need something like that.

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