perf_hooks: fix histogram fast call signatures · nodejs/node@a722f67 · GitHub
Skip to content

Commit a722f67

Browse files
Renegade334targos
authored andcommitted
perf_hooks: fix histogram fast call signatures
PR-URL: #59600 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent e9dad4f commit a722f67

4 files changed

Lines changed: 77 additions & 58 deletions

File tree

src/histogram.cc

Lines changed: 26 additions & 28 deletions

src/histogram.h

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,14 @@ class HistogramImpl {
101101
static void GetPercentilesBigInt(
102102
const v8::FunctionCallbackInfo<v8::Value>& args);
103103

104-
static void FastReset(v8::Local<v8::Value> unused,
105-
v8::Local<v8::Value> receiver);
106-
static double FastGetCount(v8::Local<v8::Value> unused,
107-
v8::Local<v8::Value> receiver);
108-
static double FastGetMin(v8::Local<v8::Value> unused,
109-
v8::Local<v8::Value> receiver);
110-
static double FastGetMax(v8::Local<v8::Value> unused,
111-
v8::Local<v8::Value> receiver);
112-
static double FastGetMean(v8::Local<v8::Value> unused,
113-
v8::Local<v8::Value> receiver);
114-
static double FastGetExceeds(v8::Local<v8::Value> unused,
115-
v8::Local<v8::Value> receiver);
116-
static double FastGetStddev(v8::Local<v8::Value> unused,
117-
v8::Local<v8::Value> receiver);
118-
static double FastGetPercentile(v8::Local<v8::Value> unused,
119-
v8::Local<v8::Value> receiver,
104+
static void FastReset(v8::Local<v8::Value> receiver);
105+
static double FastGetCount(v8::Local<v8::Value> receiver);
106+
static double FastGetMin(v8::Local<v8::Value> receiver);
107+
static double FastGetMax(v8::Local<v8::Value> receiver);
108+
static double FastGetMean(v8::Local<v8::Value> receiver);
109+
static double FastGetExceeds(v8::Local<v8::Value> receiver);
110+
static double FastGetStddev(v8::Local<v8::Value> receiver);
111+
static double FastGetPercentile(v8::Local<v8::Value> receiver,
120112
const double percentile);
121113

122114
static void AddMethods(v8::Isolate* isolate,
@@ -165,13 +157,8 @@ class HistogramBase final : public BaseObject, public HistogramImpl {
165157
static void RecordDelta(const v8::FunctionCallbackInfo<v8::Value>& args);
166158
static void Add(const v8::FunctionCallbackInfo<v8::Value>& args);
167159

168-
static void FastRecord(
169-
v8::Local<v8::Value> unused,
170-
v8::Local<v8::Value> receiver,
171-
const int64_t value,
172-
v8::FastApiCallbackOptions& options); // NOLINT(runtime/references)
173-
static void FastRecordDelta(v8::Local<v8::Value> unused,
174-
v8::Local<v8::Value> receiver);
160+
static void FastRecord(v8::Local<v8::Value> receiver, const int64_t value);
161+
static void FastRecordDelta(v8::Local<v8::Value> receiver);
175162

176163
HistogramBase(
177164
Environment* env,
@@ -243,11 +230,8 @@ class IntervalHistogram final : public HandleWrap, public HistogramImpl {
243230
static void Start(const v8::FunctionCallbackInfo<v8::Value>& args);
244231
static void Stop(const v8::FunctionCallbackInfo<v8::Value>& args);
245232

246-
static void FastStart(v8::Local<v8::Value> unused,
247-
v8::Local<v8::Value> receiver,
248-
bool reset);
249-
static void FastStop(v8::Local<v8::Value> unused,
250-
v8::Local<v8::Value> receiver);
233+
static void FastStart(v8::Local<v8::Value> receiver, bool reset);
234+
static void FastStop(v8::Local<v8::Value> receiver);
251235

252236
BaseObject::TransferMode GetTransferMode() const override {
253237
return TransferMode::kCloneable;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Flags: --expose-internals --no-warnings --allow-natives-syntax
2+
'use strict';
3+
4+
const common = require('../common');
5+
const assert = require('assert');
6+
7+
const { internalBinding } = require('internal/test/binding');
8+
9+
const histogram = require('perf_hooks').createHistogram();
10+
11+
function testFastMethods() {
12+
histogram.record(1);
13+
histogram.recordDelta();
14+
histogram.percentile(50);
15+
histogram.reset();
16+
}
17+
18+
eval('%PrepareFunctionForOptimization(histogram.record)');
19+
eval('%PrepareFunctionForOptimization(histogram.recordDelta)');
20+
eval('%PrepareFunctionForOptimization(histogram.percentile)');
21+
eval('%PrepareFunctionForOptimization(histogram.reset)');
22+
testFastMethods();
23+
eval('%OptimizeFunctionOnNextCall(histogram.record)');
24+
eval('%OptimizeFunctionOnNextCall(histogram.recordDelta)');
25+
eval('%OptimizeFunctionOnNextCall(histogram.percentile)');
26+
eval('%OptimizeFunctionOnNextCall(histogram.reset)');
27+
testFastMethods();
28+
29+
if (common.isDebug) {
30+
const { getV8FastApiCallCount } = internalBinding('debug');
31+
assert.strictEqual(getV8FastApiCallCount('histogram.record'), 1);
32+
assert.strictEqual(getV8FastApiCallCount('histogram.recordDelta'), 1);
33+
assert.strictEqual(getV8FastApiCallCount('histogram.percentile'), 1);
34+
assert.strictEqual(getV8FastApiCallCount('histogram.reset'), 1);
35+
}

test/parallel/test-perf-hooks-histogram.js

Lines changed: 4 additions & 2 deletions

0 commit comments

Comments
 (0)