Example flamegraph

Instructions

Requirements

The steps for Mac and Linux are explained below, but in both cases ensure to run your app with node version >=0.11.3.

Note: the .cpuprofile files from the Google Chrome DevTools profiler can no longer be loaded directly as a Callgraph since the format changed.

For more info and where to start fixing it please see this issue.

Mac

Create a Callgraph

Install cpuprofilify

Run your app with DTrace

sudo profile_1ms.d -c 'node --perf-basic-prof <app>' > dtrace.txt

Load dtrace.txt into the app as well as /tmp/perf-<pid>.map

Alternatively pipe through cpuprofilify:

cat dtrace.txt | cpuprofilify > dtrace.cpuprofile

and load that into DevTools or the flamegraph app.

One liner for the above:

sudo profile_1ms.d -c 'node --perf-basic-prof <app>' > | cpuprofilify > dtrace.cpuprofile

Make sure to cleanly shutdown your app so the symbols files can be written, see here

Linux

Create Callgraph

Run your app with perf:

perf record -e cycles:u -g -- node --perf-basic-prof app.js

Extract trace from perf.data file

perf script > perf-script.txt

Load

Just loading the perf-script.txt file as the Callgraph suffices since perf already resolved the symbols.

JavaScript only Flamegraphs Anywhere

Create a cpuprofile with v8-profiler and load that into the app

Fork me on GitHub