Easy flamegraphs, with diffs, for Node.js and Chrome
npm install pflamespflames is a tool for generating
flamegraphs from various profile
formats.
The following formats are supported (detected by file extension):
.cpuprofile, as generated by older Chrome DevTools,
v8-profiler,
cli-profile, etc.
* perf.data, as generated by perf record on Linux.
isolate.log, as generated by node --prof.
The data is processed from these formats into flamegraphs generated by Brendan
Gregg's FlameGraph tool, saved to
a local file based on the input filename, then immediately opened in your web
browser.
Examples:
```
$ npm i -g cli-profile
$ cli-profile myscript.js
$ ls *.cpuprofile
profile1522910623600.cpuprofile
$ pflames profile1522910623600.cpuprofile
`process.on('SIGINT', process.exit)
$ # Note: Ensure your script has `
$ node --prof myscript.js
$ ls *.log
isolate-0x2259700-v8.log
$ pflames isolate-0x2259700-v8.log
``
$ sudo perf record -i -g -F 99 -- node --perf-basic-prof myscript.js
$ pflames perf.data
You can also compare two profiles of the same format by passing them both in. A
difference flamegraph will be generated:
``
$ pflames thing1.cpuprofile thing2.cpuprofile
You can also use the same data to generate an icicle graph, so you can get a
better view of what's calling a heavy function:
``
$ pflames --icicle thing1.cpuprofile
You can use the run and attach commands to profile Node.js and other Linuxperf record
processes. This will run behind the scenese to generate aperf.data.
* run spawns a process with the given command with perf record, profilingnode
it for its entire lifetime. If the process binary being run is , it will--perf-basic-prof
add to the options. Examples:
``profile a Node.js app
$ pflames run node myapp.jsprofile a Rust app (you should use release builds for this)
$ pflames run target/release/myapp
* attach starts profiling a given PID until the that process exits, a
SIGINT (Ctrl+C) is received, or a given number of seconds has elapsed.
``Assume PID 1234 is running and we want to profile it:
$ pflames attach 1234Now either Ctrl+C to finish profiling or wait for 1234 to finish
Or profile it for exactly 5 seconds:
$ pflames attach 1234 5
Both of these commands produce perf.data files which can be then processedplfames
with :
```
$ pflames perf.data
MIT License. See LICENSE.txt