-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: add inspector API example for heapdump
PR-URL: #26498 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
1 parent
8d669bb
commit a445244
Showing
2 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
|
||
common.skipIfInspectorDisabled(); | ||
|
||
// Test that example code in doc/api/inspector.md continues to work with the V8 | ||
// experimental API. | ||
|
||
const assert = require('assert'); | ||
const inspector = require('inspector'); | ||
const session = new inspector.Session(); | ||
|
||
session.connect(); | ||
|
||
const chunks = []; | ||
|
||
session.on('HeapProfiler.addHeapSnapshotChunk', (m) => { | ||
chunks.push(m.params.chunk); | ||
}); | ||
|
||
session.post('HeapProfiler.takeHeapSnapshot', null, common.mustCall((e, r) => { | ||
assert.ifError(e); | ||
assert.deepStrictEqual(r, {}); | ||
session.disconnect(); | ||
|
||
const profile = JSON.parse(chunks.join('')); | ||
assert(profile.snapshot.meta); | ||
assert(profile.snapshot.node_count > 0); | ||
assert(profile.snapshot.edge_count > 0); | ||
})); |