forked from hyj1991/v8-profiler-next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
192 lines (165 loc) · 4.2 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
import { Stream } from "stream";
/**
*
* @param type 0 for "flat" profile, 1 for "tree" profile
*/
export function setGenerateType(type: 0 | 1): void;
/**
*
* @param limit Maximum number of profiles to keep in memory
*/
export function setProfilesCleanupLimit(limit: number): void;
/**
*
* @param num Sampling interval in bytes. Default is 512 * 1024.
*/
export function setSamplingInterval(num: number): void;
/**
* Collects a sample.
*/
export function collectSample(): void;
/**
* Starts the profiler with a new profile.
* @param name Name for the profile. "undefined" if not defined.
* @param recsamples Is true by default.
*/
export function startProfiling(recsamples?: boolean): void;
export function startProfiling(name?: string, recsamples?: boolean, mode?: 0 | 1): void;
/**
* Stops the profiler for a specific profile.
* @param name Name of the profile. "undefined" if not defined.
*/
export function stopProfiling(name?: string): CpuProfile;
/**
* Deletes all profiles.
*/
export function deleteAllProfiles(): void;
/**
* Deletes all snapshots.
*/
export function deleteAllSnapshots(): void;
/**
* Starts the sampling profiler with a new profile.
*/
export function startSamplingHeapProfiling(): void;
export function startSamplingHeapProfiling(
interval: number,
depth: number
): void;
/**
* Stops the sampling profiler for a specific profile.
*/
export function stopSamplingHeapProfiling(): SamplingHeapProfile;
export function getHeapStats(
iterator: Function | undefined,
callback: Function | undefined
): number;
/**
*
* @param id Heap object id
*/
export function getObjectByHeapObjectId(id: number): Object;
/**
* Starts tracking heap objects.
*/
export function startTrackingHeapObjects(): void;
/**
* Stops tracking heap objects.
*/
export function stopTrackingHeapObjects(): void;
/**
*
* @param value Object to get the heap object id from
*/
export function getHeapObjectId(value: Object): number;
/**
* Takes a snapshot.
* @param name Name of the snapshot
* @param control Function to execute
*/
export function takeSnapshot(control?: Function): Snapshot;
export function takeSnapshot(name?: string, control?: Function): Snapshot;
export let snapshots: { [key: string]: Snapshot };
export let profiles: Profile[];
export class Profile {
/**
* Exports data of the profile.
* @param dataReceiver Can be a stream or callback. If not defined or a stream, returns a new stream.
*/
export(dataReceiver?: Stream): ExportStream;
export(dataReceiver: DataReceiver): void;
}
export class SamplingHeapProfile extends Profile {
head: SamplingHeapProfileNode;
}
export class CpuProfile extends Profile {
getHeader(): Header;
delete(): void;
endTime: Date;
startTime: Date;
head: CpuProfileNode;
samples: number[];
timestamps: number[];
typeId: string;
uid: string;
title: string;
}
/**
* @param error Error if the CpuProfiler encountered an error
* @param result Result as stringified JSON object
*/
type DataReceiver = (
error: Error | undefined,
result: string | undefined
) => void;
export class ExportStream extends Stream.Transform { }
export class Snapshot extends Profile {
getHeader(): Header;
compare(other: Snapshot): Object;
getNode(index: number): SnapshotNode;
getNodeById(id: number): SnapshotNode; // todo: NOT WORKING
serialize(iterator: Function, callback: Function): void;
delete(): Object;
root: SnapshotNode;
typeId: string;
title: string;
uid: number;
nodesCount: number;
maxSnapshotJSObjectId: number;
}
export interface SnapshotNode {
children: SnapshotNode[];
type: string;
name: string;
id: number;
shallowSize: number;
from?: SnapshotNode;
to?: SnapshotNode;
}
export interface Header {
typeId: string;
uid: string;
title: string;
}
export interface CpuProfileNode {
functionName: string;
url: string;
lineNumber: number;
callUID?: number;
bailoutReason: string;
id: number;
scriptId: number;
hitCount: number;
children: CpuProfileNode[];
}
export interface SamplingHeapProfileNode {
callframe: {
functionName: string;
scriptId: number;
url: string;
lineNumber: number;
columnNumber: number;
};
selfSize: number;
children: SamplingHeapProfileNode[];
}