Skip to content

Commit

Permalink
doc: fix/improve inspector profiler example
Browse files Browse the repository at this point in the history
The first parameter to the callback is `err`. Fix that. Expand example
to demonstrate an actual write to disk.

PR-URL: #19379
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
ofrobots authored and MylesBorins committed Mar 22, 2018
1 parent 29a04b7 commit cc7ba0b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions doc/api/inspector.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ protocol. Here's a simple example showing how to use the [CPU profiler][]:

```js
const inspector = require('inspector');

const fs = require('fs');
const session = new inspector.Session();
session.connect();

Expand All @@ -154,8 +154,11 @@ session.post('Profiler.enable', () => {
// invoke business logic under measurement here...

// some time later...
session.post('Profiler.stop', ({ profile }) => {
session.post('Profiler.stop', (err, { profile }) => {
// write profile to disk, upload, etc.
if (!err) {
fs.writeFileSync('./profile.cpuprofile', JSON.stringify(profile));
}
});
});
});
Expand Down

0 comments on commit cc7ba0b

Please sign in to comment.