Skip to content

Instantly share code, notes, and snippets.

@psiphi75
Created February 13, 2017 01:31
Show Gist options
  • Save psiphi75/99ac5f583b9e09b0c51df4f087c8eca3 to your computer and use it in GitHub Desktop.
Save psiphi75/99ac5f583b9e09b0c51df4f087c8eca3 to your computer and use it in GitHub Desktop.
Create a CPU profile using Node.js and v8-profiler
var profiler = require('v8-profiler');
var fs = require('fs');
var processStartTime = new Date().getTime();
profiler.startProfiling();
while (true) {
rt.renderFrame(done);
if (new Date().getTime() - processStartTime > 60000) {
console.log(`frames,${frames}`);
profiler.stopProfiling().export(function(error, result) {
fs.writeFileSync('profile.cpuprofile', result);
process.exit();
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment