From 2725acf1c20986767ddbe009c6bb4c862e9b9fbf Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Thu, 15 Mar 2018 15:44:04 -0700 Subject: doc: fix/improve inspector profiler example The first parameter to the callback is `err`. Fix that. Expand example to demonstrate an actual write to disk. PR-URL: https://github.com/nodejs/node/pull/19379 Reviewed-By: Colin Ihrig Reviewed-By: Richard Lau Reviewed-By: Franziska Hinkelmann Reviewed-By: James M Snell Reviewed-By: Luigi Pinca --- doc/api/inspector.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'doc/api/inspector.md') diff --git a/doc/api/inspector.md b/doc/api/inspector.md index c801510b75..9dafdb7e1b 100644 --- a/doc/api/inspector.md +++ b/doc/api/inspector.md @@ -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(); @@ -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)); + } }); }); }); -- cgit v1.2.3