HeapSnapshot
Representation for iterating over a snapshot's Nodes and Edges. The structure of a snapshot's Node and Edge is defined within the contents of the snapshot.
Constructor Summary
| Public Constructor | ||
| public |
constructor(provider: SplitSnapshotProvider) |
|
Method Summary
| Public Methods | ||
| public |
getNode(node_index: number): NodeResult Gets a Node by index, not by ID. |
|
| public |
getNodeById(node_id: number): NodeResult Gets a Node by ID. |
|
| public |
Gets a Sample by index. |
|
| public |
Walks over all the Samples in the HeapSnapshot in order. |
|
| public |
walk(callbacks: WalkCallbacks): Iterator Helper function that performs a depth first pre order traversal of the nodes of a HeapSnapshot. |
|
Public Constructors
public constructor(provider: SplitSnapshotProvider) source
Params:
| Name | Type | Attribute | Description |
| provider | SplitSnapshotProvider | Snapshot data provider |
Public Methods
public getNode(node_index: number): NodeResult source
Gets a Node by index, not by ID. The root Node is at index 0.
Params:
| Name | Type | Attribute | Description |
| node_index | number |
Example:
const root = snapshot.getNode(0);
public getNodeById(node_id: number): NodeResult source
Gets a Node by ID. This can be SIGNIFICANTLY SLOWER than looking up the Node by index since IDs are sparse.
Params:
| Name | Type | Attribute | Description |
| node_id | number |
Example:
const myNode = snapshot.getNodeById(42);
public getSample(sample_index: number): Sample source
Gets a Sample by index.
Params:
| Name | Type | Attribute | Description |
| sample_index | number |
Example:
const first = snapshot.getSample(0);
const second = snapshot.getSample(1);
console.log('delay', second.time - first.time);
public walk(callbacks: WalkCallbacks): Iterator source
Helper function that performs a depth first pre order traversal of the nodes of a HeapSnapshot. This will only visit each Node once, but will visit all Edges of a HeapSnapshot. Since this can be a costly operation it uses an iterator to allow chunked processing.
Params:
| Name | Type | Attribute | Description |
| callbacks | WalkCallbacks |
Return:
| Iterator | iterator to continue walking by calling .next |
Example:
let walker = walk(console.log);
// the iterator does not return a value it is purely a controller
for (const _ of walker) {}