GitXplorerGitXplorer
m

node-flame-graph

public
9 stars
0 forks
2 issues

Commits

List of commits on branch master.
Verified
41359309f2916d3be99855e5fb0a03c6cf9c69d9

Merge pull request #4 from maxbrunsfeld/dependabot/npm_and_yarn/minimist-1.2.6

mmaxbrunsfeld committed 3 years ago
Verified
df205ddae6cef1e127975441d9b59c67f96be418

Bump minimist from 1.2.2 to 1.2.6

ddependabot[bot] committed 3 years ago
Unverified
a52df502a35213331145eb063c2e679db9485a1c

Preserve env vars when using sudo to run dtrace

mmaxbrunsfeld committed 5 years ago
Verified
be3a2f8b7b078221d3ffe5be66273644f1463007

Merge pull request #2 from maxbrunsfeld/dependabot/npm_and_yarn/minimist-1.2.2

committed 5 years ago
Verified
0d0e53f1f09132f4be80a6f448d98a7405f3f165

Bump minimist from 1.2.0 to 1.2.2

ddependabot[bot] committed 5 years ago
Unverified
86d68c33c7161f92b5b731569ddf0ecc5c59c4f5

Limit recursion depth when aggregating call stacks

mmaxbrunsfeld committed 5 years ago

README

The README file for this repository.

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)
}