@@ -79,10 +79,14 @@ NAN_METHOD(StartSamplingHeapProfiler) {
79
79
}
80
80
}
81
81
82
+ // Signature:
83
+ // stopSamplingHeapProfiler()
82
84
NAN_METHOD (StopSamplingHeapProfiler) {
83
85
info.GetIsolate ()->GetHeapProfiler ()->StopSamplingHeapProfiler ();
84
86
}
85
87
88
+ // Signature:
89
+ // getAllocationProfile(): AllocationProfileNode
86
90
NAN_METHOD (GetAllocationProfile) {
87
91
std::unique_ptr<v8::AllocationProfile> profile (
88
92
info.GetIsolate ()->GetHeapProfiler ()->GetAllocationProfile ());
@@ -130,7 +134,7 @@ Local<Array> GetLineNumberTimeProfileChildren(const CpuProfileNode* parent,
130
134
unsigned int hitLineCount = node->GetHitLineCount ();
131
135
unsigned int hitCount = node->GetHitCount ();
132
136
if (hitLineCount > 0 ) {
133
- std::vector< CpuProfileNode::LineTick> entries ( hitLineCount) ;
137
+ CpuProfileNode::LineTick entries[ hitLineCount] ;
134
138
node->GetLineTicks (&entries[0 ], hitLineCount);
135
139
children = Nan::New<Array>(count + entries.size ());
136
140
for (const CpuProfileNode::LineTick entry : entries) {
@@ -260,6 +264,8 @@ Local<Value> TranslateTimeProfile(const CpuProfile* profile, bool hasDetailedLin
260
264
return js_profile;
261
265
}
262
266
267
+ // Signature:
268
+ // startProfiling(runName: string, includeLineInfo?: boolean)
263
269
NAN_METHOD (StartProfiling) {
264
270
if (info.Length () != 2 ) {
265
271
return Nan::ThrowTypeError (" StartProfling must have two arguments." );
@@ -274,23 +280,26 @@ NAN_METHOD(StartProfiling) {
274
280
Local<String> name =
275
281
Nan::MaybeLocal<String>(info[0 ].As <String>()).ToLocalChecked ();
276
282
283
+ // Sample counts and timestamps are not used, so we do not need to record
284
+ // samples.
285
+ bool recordSamples = false ;
286
+
277
287
// Line-level accurate line information is not available in Node 11 or earlier.
278
288
#if NODE_MODULE_VERSION > NODE_11_0_MODULE_VERSION
279
289
bool includeLineInfo =
280
290
Nan::MaybeLocal<Boolean>(info[1 ].As <Boolean>()).ToLocalChecked ()->Value ();
281
291
if (includeLineInfo) {
282
- // Sample counts and timestamps are not used, so we do not need to record
283
- // samples.
284
292
cpuProfiler->StartProfiling (name, CpuProfilingMode::kCallerLineNumbers ,
285
- false );
293
+ recordSamples );
286
294
} else {
287
- cpuProfiler->StartProfiling (name, false );
295
+ cpuProfiler->StartProfiling (name, recordSamples );
288
296
}
289
297
#else
290
- cpuProfiler->StartProfiling (name, false );
298
+ cpuProfiler->StartProfiling (name, recordSamples );
291
299
#endif
292
300
}
293
301
302
+ // Signature:
294
303
// stopProfiling(runName: string, includedLineInfo?: boolean): TimeProfile
295
304
NAN_METHOD (StopProfiling) {
296
305
if (info.Length () != 2 ) {
@@ -314,6 +323,8 @@ NAN_METHOD(StopProfiling) {
314
323
info.GetReturnValue ().Set (translated_profile);
315
324
}
316
325
326
+ // Signature:
327
+ // setSamplingInterval(intervalMicros: number)
317
328
NAN_METHOD (SetSamplingInterval) {
318
329
#if NODE_MODULE_VERSION > NODE_8_0_MODULE_VERSION
319
330
int us = info[0 ].As <Integer>()->Value ();
0 commit comments