Skip to content

Instantly share code, notes, and snippets.

@Unitech
Created May 28, 2015 04:03
Show Gist options
  • Select an option

  • Save Unitech/f7e2110e7a0a2e3bfb22 to your computer and use it in GitHub Desktop.

Select an option

Save Unitech/f7e2110e7a0a2e3bfb22 to your computer and use it in GitHub Desktop.
var fs = require('fs');
profiler.startProfiling('toto')
setTimeout(function() {
var cpu = profiler.stopProfiling('toto');
var snapshot = profiler.takeSnapshot('sisi');
var buffer = '';
snapshot.serialize(
function iterator(data, length) {
buffer += data;
}, function complete() {
var name = 'snap.heapsnapshot';
fs.writeFile(name , buffer, function () {
console.log('Heap snapshot written to ' + name);
});
}
);
fs.writeFileSync('heap.cpuprofile', JSON.stringify(cpu));
console.log('worte');
}, 2000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment