node bindings for the v8 profiler
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 4 commits ahead of NodeFly:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
.npmignore
LICENSE
Makefile
binding.gyp
cpu_profiler.cc
cpu_profiler.h
heap_profiler.cc
heap_profiler.h
index.js
package.json
profile.cc
profile.h
profile_node.cc
profile_node.h
profiler.cc
readme.md
snapshot.cc
snapshot.h
wscript

readme.md

v8-profiler provides node bindings for the v8 profiler and integration with node-inspector

Installation

npm install another-v8-profiler

We now include node v0.10 binaries for a number of platforms. During the install, node-gyp will attempt to build the module for your platform. If it fails (see builderror.log), the module will still be installed, but will attempt to load up an appropriate pre-built binary for your platform if there is one available.

Usage

var profiler = require('another-v8-profiler');

API

######Profiler Object

name type
heapProfiler HeapProfiler
cpuProfiler CpuProfiler

######CpuProfiler Object

name type args description
getProfilesCount method none returns the count of stored profiles
getProfile method int index gets a profile by it's index between 0 and count-1
findProfile method int uid searches stored profiles by uid
startProfiling method string name starts profiling the current process
stopProfiling method string name stops profiling the current process
deleteAllProfiles method none removes all stored profiles

######CpuProfile Object

name type
title string
uid string
topRoot CpuProfileNode
bottomRoot CpuProfileNode
delete method

######CpuProfileNode Object |name|type|args|description |----|----|----|----------- |functionName |string|-| |scriptName |string|-| |lineNumber |number|-| |totalTime |number|-| |selfTime |number|-| |totalSamplesCount |number|-| |selfSamplesCount |number|-| |callUid |number|-| |childrenCount |number|-| |getChild |method|-|returns CpuProfileNode

######HeapProfiler Object |name|type|args|description |----|----|----|----------- |getSnapshotsCount |method|-| |getSnapshot |method|number index| |findSnapshot |method|number uid| |takeSnapshot |method|string name|

######HeapSnapshot Object

name type args description
getTitle method - returns the title of the snapshot
getUid method - returns the snapshot's Uid
getType method - currenlty V8 snapshots only support 'full'
serialize method opts={onData: callback, onEnd: callback} ) serializes the snapshot to json
delete method - deletes this snapshot
save method string filename serializes and saves the snapshot to a file path (folder path must exist before saving)

Examples

var profiler = require('another-v8-profiler');
var heapProfiler = profiler.heapProfiler;
var snapshot = heapProfiler.takeSnapshot([name])    // takes a heap snapshot
snapshot.save(filename);                            // save the snapshot to file
snapshot.delete();                                  // delete the snapshot (releases memory)
var profiler = require('another-v8-profiler');
var cpuProfiler = profiler.cpuProfiler;
cpuProfiler.startProfiling([name])                  // begin cpu profiling
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.