The Wayback Machine - https://web.archive.org/web/20210101191712/https://github.com/maxbrunsfeld/node-flame-graph
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
doc
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

flame-graph

Build Status

This library makes it easy to profile a process with dtrace on macOS and to format the results as a Flame Graph.

flame graph example

To use this tool within Atom, try the flame-graph Atom package.

Installation

npm install @maxbrunsfeld/flame-graph

Command Line Usage

To profile a running process:

$ generate-flame-graph -p $PID_TO_PROFILE

To stop profiling, kill the process with Control+C.

To create and profile a child process with a given command:

$ generate-flame-graph -c './test arg1 arg2'

Often, you're only interested in profiling a certain function (or functions). You can do this using the optional -f/--functions flag:

$ generate-flame-graph -p $PID --functions 'function1 function2'

Programmatic Usage

All of the functionality shown above is accessible programatically.

const {
  generateFlameGraphForCommand,
  generateFlameGraphForProcess
} = require('@maxbrunsfeld/flame-graph')

async function test1 () {
  // Create and profile a child process
  console.log(await generateFlameGraphForCommand(
    './test arg1 arg2'
    {
      functionNames: ['function1', 'function2']
    }
  ))

  // Profile a running process
  const flameGraph = generateFlameGraphForProcess(
    pidToProfile,
    {
      functionNames: ['function1', 'function2']
    }
  )

  setTimeout(() => flameGraph.stop(), 100)
  console.log(await flameGraph.html)
}

About

A tool for generating flame graphs of CPU profiling data

Resources

License

Packages

No packages published
You can’t perform that action at this time.