Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const inspector = require('inspector');
- const fs = require('fs');
- const session = new inspector.Session();
- session.connect();
- session.post('Profiler.enable', () => {
- session.post('Profiler.start', () => {
- // Invoke business logic under measurement here...
- // some time later...
- session.post('Profiler.stop', (err, { profile }) => {
- // Write profile to disk, upload, etc.
- if (!err) {
- fs.writeFileSync('./profile.cpuprofile', JSON.stringify(profile));
- }
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement