# pflames

> Easy flamegraphs, with diffs, for Node.js and Chrome

Latest version **1.1.0** (published 2019-07-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install pflames
pnpm add pflames
yarn add pflames
bun add pflames
```

Provides the command `pflames`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2019-07-05 |
| First published | 2018-04-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 11.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 33 |
| Author | Bryan English |
| Maintainers | bengl |
| Keywords | flamegraph, flamechart, performance, perf |

## Links

- npm: https://www.npmjs.com/package/pflames
- Repository: https://github.com/bengl/pflames
- Homepage: https://github.com/bengl/pflames#readme
- Issues: https://github.com/bengl/pflames/issues
- npm.io page: https://npm.io/package/pflames

## Dependencies (2)

- [opn](https://npm.io/package/opn.md) ^5.3.0
- [cpuprofile2stackcollapse](https://npm.io/package/cpuprofile2stackcollapse.md) ^1.0.0

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2019-07-05
- 1.0.1 — 2019-06-29
- 1.0.0 — 2018-04-27

## README

# pflames

**`pflames`** is a tool for generating
[flamegraphs](http://www.brendangregg.com/flamegraphs.html) from various profile
formats.

The following formats are supported (detected by file extension):

* **`*.cpuprofile`**, as generated by older Chrome DevTools,
  [v8-profiler](https://npm.im/v8-profiler),
  [cli-profile](https://npm.im/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](https://github.com/brendangregg/FlameGraph) tool, saved to
a local file based on the input filename, then immediately opened in your web
browser.

## Usage

Examples:

```
$ npm i -g cli-profile
$ cli-profile myscript.js
$ ls *.cpuprofile
profile1522910623600.cpuprofile
$ pflames profile1522910623600.cpuprofile
```

```
$ # Note: Ensure your script has `process.on('SIGINT', process.exit)`
$ 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
```

### Easily create `perf.data` files (Linux only)

You can use the `run` and `attach` commands to profile Node.js and other Linux
processes. This will run `perf record` behind the scenese to generate a
`perf.data`.

* **`run`** spawns a process with the given command with `perf record`, profiling
it for its entire lifetime. If the process binary being run is `node`, it will
add `--perf-basic-prof` to the options. Examples:

```
# profile a Node.js app
$ pflames run node myapp.js
# profile 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 1234
# Now 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 processed
with `plfames`:

```
$ pflames perf.data
```

## License

MIT License. See LICENSE.txt

---
_Source: https://npm.io/package/pflames · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
