CPU profiling with Chrome Devtools

From Node version 6.3.x it's possible to use the --inspect flag to allow a Node process to be debugged and profiled with Chrome Devtools.

Let's try it:

$ node --inspect server.jsDebugger listening on port 9229.Warning: This is an experimental feature and could change at any time.To start debugging, open the following URL in Chrome:     chrome-devtools://devtools/remote/serve_file/@60cd6e859b9f557d2312f5bf532f6aec5f284980/inspector.html?experiments=true&v8only=true&ws=localhost:9229/node
  

If we copy and paste the entire chrome-devtools:// URL into Chrome we should get an instance of Chrome Devtools connected to our process.

Now we can select the Profiles tab, select the Record JavaScript CPU profile, and hit ...

Get Node Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.