Skip to content

Commit bc0a59c

Browse files
committed
perf_hooks: test event loop delay fast api callbacks
Add test coverage for the per iteration event loop delay histogram start and stop callbacks Use disitinct debug tracking keys for the event loop delay histogram callbacks.
1 parent 116cd3f commit bc0a59c

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

src/histogram.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ void ELDHistogram::Start(const FunctionCallbackInfo<Value>& args) {
596596
}
597597

598598
void ELDHistogram::FastStart(Local<Value> receiver, bool reset) {
599-
TRACK_V8_FAST_API_CALL("histogram.start");
599+
TRACK_V8_FAST_API_CALL("histogram.eventLoopDelay.start");
600600
ELDHistogram* histogram;
601601
ASSIGN_OR_RETURN_UNWRAP(&histogram, receiver);
602602
histogram->OnStart(reset ? StartFlags::RESET : StartFlags::NONE);
@@ -609,7 +609,7 @@ void ELDHistogram::Stop(const FunctionCallbackInfo<Value>& args) {
609609
}
610610

611611
void ELDHistogram::FastStop(Local<Value> receiver) {
612-
TRACK_V8_FAST_API_CALL("histogram.stop");
612+
TRACK_V8_FAST_API_CALL("histogram.eventLoopDelay.stop");
613613
ELDHistogram* histogram;
614614
ASSIGN_OR_RETURN_UNWRAP(&histogram, receiver);
615615
histogram->OnStop();
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Flags: --allow-natives-syntax --expose-internals --no-warnings
2+
'use strict';
3+
4+
const common = require('../common');
5+
const assert = require('assert');
6+
7+
const { internalBinding } = require('internal/test/binding');
8+
const { createELDHistogram } = internalBinding('performance');
9+
10+
const histogram = createELDHistogram(1, true);
11+
12+
function testFastMethods() {
13+
histogram.start(true);
14+
histogram.stop();
15+
}
16+
17+
eval('%PrepareFunctionForOptimization(testFastMethods)');
18+
testFastMethods();
19+
eval('%OptimizeFunctionOnNextCall(testFastMethods)');
20+
testFastMethods();
21+
22+
if (common.isDebug) {
23+
const { getV8FastApiCallCount } = internalBinding('debug');
24+
assert.strictEqual(getV8FastApiCallCount('histogram.eventLoopDelay.start'), 1);
25+
assert.strictEqual(getV8FastApiCallCount('histogram.eventLoopDelay.stop'), 1);
26+
}

0 commit comments

Comments
 (0)