Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document that profiles are jsonable to .cpuprofile files #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Build status](https://ci.appveyor.com/api/projects/status/hhgloy5smkl5i8fd/branch/master?svg=true)](https://ci.appveyor.com/project/3y3/v8-profiler/branch/master)
[![npm version](https://badge.fury.io/js/v8-profiler.svg)](http://badge.fury.io/js/v8-profiler)

v8-profiler provides [node](http://github.com/ry/node) bindings for the v8
v8-profiler provides [node](http://github.com/ry/node) bindings for the v8
profiler and integration with [node-inspector](http://github.com/dannycoates/node-inspector)

## Installation
Expand All @@ -18,9 +18,16 @@ profiler and integration with [node-inspector](http://github.com/dannycoates/nod
var snapshot = profiler.takeSnapshot([name]) //takes a heap snapshot

profiler.startProfiling([name]) //begin cpu profiling
// ... do your program's work ...
var cpuProfile = profiler.stopProfiling([name]) //finish cpu profiling

## node-inspector

Cpu profiles can be viewed and heap snapshots may be taken and viewed from the
profiles panel.
CPU profiles can be viewed and heap snapshots may be taken and viewed from the
profiles panel. The profiles returned are JSONable objects in the `.cpuprofile`
format that node-inspector's `Profiles` panel loads.

var serialized = JSON.stringify(cpuProfile, null, 2);
require('fs').writeFileSync('myprogram.cpuprofile', serialized, 'utf8');

The `myprogram.cpuprofile` file written can then be loaded into the profiles panel and viewed as a flamechart.