Skip to content

Commit 4a33bf5

Browse files
committed
address comments
1 parent 764c242 commit 4a33bf5

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

bindings/profiler.cc

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,14 @@ NAN_METHOD(StartSamplingHeapProfiler) {
7979
}
8080
}
8181

82+
// Signature:
83+
// stopSamplingHeapProfiler()
8284
NAN_METHOD(StopSamplingHeapProfiler) {
8385
info.GetIsolate()->GetHeapProfiler()->StopSamplingHeapProfiler();
8486
}
8587

88+
// Signature:
89+
// getAllocationProfile(): AllocationProfileNode
8690
NAN_METHOD(GetAllocationProfile) {
8791
std::unique_ptr<v8::AllocationProfile> profile(
8892
info.GetIsolate()->GetHeapProfiler()->GetAllocationProfile());
@@ -130,7 +134,7 @@ Local<Array> GetLineNumberTimeProfileChildren(const CpuProfileNode* parent,
130134
unsigned int hitLineCount = node->GetHitLineCount();
131135
unsigned int hitCount = node->GetHitCount();
132136
if (hitLineCount > 0) {
133-
std::vector<CpuProfileNode::LineTick> entries(hitLineCount);
137+
CpuProfileNode::LineTick entries[hitLineCount];
134138
node->GetLineTicks(&entries[0], hitLineCount);
135139
children = Nan::New<Array>(count + entries.size());
136140
for (const CpuProfileNode::LineTick entry : entries) {
@@ -260,6 +264,8 @@ Local<Value> TranslateTimeProfile(const CpuProfile* profile, bool hasDetailedLin
260264
return js_profile;
261265
}
262266

267+
// Signature:
268+
// startProfiling(runName: string, includeLineInfo?: boolean)
263269
NAN_METHOD(StartProfiling) {
264270
if (info.Length() != 2) {
265271
return Nan::ThrowTypeError("StartProfling must have two arguments.");
@@ -274,23 +280,26 @@ NAN_METHOD(StartProfiling) {
274280
Local<String> name =
275281
Nan::MaybeLocal<String>(info[0].As<String>()).ToLocalChecked();
276282

283+
// Sample counts and timestamps are not used, so we do not need to record
284+
// samples.
285+
bool recordSamples = false;
286+
277287
// Line-level accurate line information is not available in Node 11 or earlier.
278288
#if NODE_MODULE_VERSION > NODE_11_0_MODULE_VERSION
279289
bool includeLineInfo =
280290
Nan::MaybeLocal<Boolean>(info[1].As<Boolean>()).ToLocalChecked()->Value();
281291
if (includeLineInfo) {
282-
// Sample counts and timestamps are not used, so we do not need to record
283-
// samples.
284292
cpuProfiler->StartProfiling(name, CpuProfilingMode::kCallerLineNumbers,
285-
false);
293+
recordSamples);
286294
} else {
287-
cpuProfiler->StartProfiling(name, false);
295+
cpuProfiler->StartProfiling(name, recordSamples);
288296
}
289297
#else
290-
cpuProfiler->StartProfiling(name, false);
298+
cpuProfiler->StartProfiling(name, recordSamples);
291299
#endif
292300
}
293301

302+
// Signature:
294303
// stopProfiling(runName: string, includedLineInfo?: boolean): TimeProfile
295304
NAN_METHOD(StopProfiling) {
296305
if (info.Length() != 2) {
@@ -314,6 +323,8 @@ NAN_METHOD(StopProfiling) {
314323
info.GetReturnValue().Set(translated_profile);
315324
}
316325

326+
// Signature:
327+
// setSamplingInterval(intervalMicros: number)
317328
NAN_METHOD(SetSamplingInterval) {
318329
#if NODE_MODULE_VERSION > NODE_8_0_MODULE_VERSION
319330
int us = info[0].As<Integer>()->Value();

0 commit comments

Comments
 (0)