npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pflames

v1.1.0

Published

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

Downloads

12

Readme

pflames

pflames 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.

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