-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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 <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Eugene Ostroukhov <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
1 parent
76c22f8
commit 5ad9929
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); | ||
})); |