Skip to content

Commit f9e014c

Browse files
committed
rename IntervalHistogram to ELDHistogram
1 parent c836052 commit f9e014c

5 files changed

Lines changed: 51 additions & 50 deletions

File tree

doc/api/perf_hooks.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,11 +1713,11 @@ added: v11.10.0
17131713
`uv_prepare_t`/`uv_check_t` hooks, so this value is ignored. It is still
17141714
validated to preserve backward compatible error behavior. Must be greater
17151715
than zero. **Default:** `10`.
1716-
* Returns: {IntervalHistogram}
1716+
* Returns: {ELDHistogram}
17171717

17181718
_This property is an extension by Node.js. It is not available in Web browsers._
17191719

1720-
Creates an `IntervalHistogram` object that samples and reports the event loop
1720+
Creates an `ELDHistogram` object that samples and reports the event loop
17211721
delay over time. The delays will be reported in nanoseconds.
17221722

17231723
Samples are taken directly from the event loop using `uv_prepare_t` and
@@ -2000,9 +2000,10 @@ added: v11.10.0
20002000

20012001
The standard deviation of the recorded event loop delays.
20022002

2003-
## Class: `IntervalHistogram extends Histogram`
2003+
## Class: `ELDHistogram extends Histogram`
20042004

2005-
A `Histogram` that is periodically updated on a given interval.
2005+
A `Histogram` that is updated on each event loop iteration via libuv
2006+
`uv_prepare_t`/`uv_check_t` hooks to measure event loop delay.
20062007

20072008
### `histogram.disable()`
20082009

@@ -2012,7 +2013,7 @@ added: v11.10.0
20122013

20132014
* Returns: {boolean}
20142015

2015-
Disables the update interval timer. Returns `true` if the timer was
2016+
Disables event loop delay sampling. Returns `true` if sampling was
20162017
stopped, `false` if it was already stopped.
20172018

20182019
### `histogram.enable()`
@@ -2023,7 +2024,7 @@ added: v11.10.0
20232024

20242025
* Returns: {boolean}
20252026

2026-
Enables the update interval timer. Returns `true` if the timer was
2027+
Enables event loop delay sampling. Returns `true` if sampling was
20272028
started, `false` if it was already started.
20282029

20292030
### `histogram[Symbol.dispose]()`
@@ -2032,7 +2033,7 @@ started, `false` if it was already started.
20322033
added: v24.2.0
20332034
-->
20342035

2035-
Disables the update interval timer when the histogram is disposed.
2036+
Disables event loop delay sampling when the histogram is disposed.
20362037

20372038
```js
20382039
const { monitorEventLoopDelay } = require('node:perf_hooks');
@@ -2043,9 +2044,9 @@ const { monitorEventLoopDelay } = require('node:perf_hooks');
20432044
}
20442045
```
20452046

2046-
### Cloning an `IntervalHistogram`
2047+
### Cloning an `ELDHistogram`
20472048

2048-
{IntervalHistogram} instances can be cloned via {MessagePort}. On the receiving
2049+
{ELDHistogram} instances can be cloned via {MessagePort}. On the receiving
20492050
end, the histogram is cloned as a plain {Histogram} object that does not
20502051
implement the `enable()` and `disable()` methods.
20512052

src/env_properties.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@
424424
V(http2stream_constructor_template, v8::ObjectTemplate) \
425425
V(http2ping_constructor_template, v8::ObjectTemplate) \
426426
V(i18n_converter_template, v8::ObjectTemplate) \
427-
V(intervalhistogram_constructor_template, v8::FunctionTemplate) \
427+
V(eldhistogram_constructor_template, v8::FunctionTemplate) \
428428
V(iter_template, v8::DictionaryTemplate) \
429429
V(js_transferable_constructor_template, v8::FunctionTemplate) \
430430
V(libuv_stream_wrap_ctor_template, v8::FunctionTemplate) \

src/histogram.cc

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ CFunction HistogramBase::fast_record_(
6464
CFunction::Make(&HistogramBase::FastRecord));
6565
CFunction HistogramBase::fast_record_delta_(
6666
CFunction::Make(&HistogramBase::FastRecordDelta));
67-
CFunction IntervalHistogram::fast_start_(
68-
CFunction::Make(&IntervalHistogram::FastStart));
69-
CFunction IntervalHistogram::fast_stop_(
70-
CFunction::Make(&IntervalHistogram::FastStop));
67+
CFunction ELDHistogram::fast_start_(
68+
CFunction::Make(&ELDHistogram::FastStart));
69+
CFunction ELDHistogram::fast_stop_(
70+
CFunction::Make(&ELDHistogram::FastStop));
7171

7272
void HistogramImpl::AddMethods(Isolate* isolate, Local<FunctionTemplate> tmpl) {
7373
// TODO(@jasnell): The bigint API variations do not yet support fast
@@ -319,25 +319,25 @@ void HistogramBase::HistogramTransferData::MemoryInfo(
319319
tracker->TrackField("histogram", histogram_);
320320
}
321321

322-
Local<FunctionTemplate> IntervalHistogram::GetConstructorTemplate(
322+
Local<FunctionTemplate> ELDHistogram::GetConstructorTemplate(
323323
Environment* env) {
324-
Local<FunctionTemplate> tmpl = env->intervalhistogram_constructor_template();
324+
Local<FunctionTemplate> tmpl = env->eldhistogram_constructor_template();
325325
if (tmpl.IsEmpty()) {
326326
Isolate* isolate = env->isolate();
327327
tmpl = NewFunctionTemplate(isolate, nullptr);
328328
tmpl->Inherit(HandleWrap::GetConstructorTemplate(env));
329329
tmpl->SetClassName(FIXED_ONE_BYTE_STRING(isolate, "Histogram"));
330330
auto instance = tmpl->InstanceTemplate();
331-
instance->SetInternalFieldCount(IntervalHistogram::kInternalFieldCount);
331+
instance->SetInternalFieldCount(ELDHistogram::kInternalFieldCount);
332332
HistogramImpl::AddMethods(isolate, tmpl);
333333
SetFastMethod(isolate, instance, "start", Start, &fast_start_);
334334
SetFastMethod(isolate, instance, "stop", Stop, &fast_stop_);
335-
env->set_intervalhistogram_constructor_template(tmpl);
335+
env->set_eldhistogram_constructor_template(tmpl);
336336
}
337337
return tmpl;
338338
}
339339

340-
void IntervalHistogram::RegisterExternalReferences(
340+
void ELDHistogram::RegisterExternalReferences(
341341
ExternalReferenceRegistry* registry) {
342342
registry->Register(Start);
343343
registry->Register(Stop);
@@ -346,7 +346,7 @@ void IntervalHistogram::RegisterExternalReferences(
346346
HistogramImpl::RegisterExternalReferences(registry);
347347
}
348348

349-
IntervalHistogram::IntervalHistogram(
349+
ELDHistogram::ELDHistogram(
350350
Environment* env,
351351
Local<Object> wrap,
352352
AsyncWrap::ProviderType type,
@@ -369,7 +369,7 @@ IntervalHistogram::IntervalHistogram(
369369
prepare_handle_.data = this;
370370
}
371371

372-
BaseObjectPtr<IntervalHistogram> IntervalHistogram::Create(
372+
BaseObjectPtr<ELDHistogram> ELDHistogram::Create(
373373
Environment* env,
374374
const Histogram::Options& options) {
375375
Local<Object> obj;
@@ -379,23 +379,23 @@ BaseObjectPtr<IntervalHistogram> IntervalHistogram::Create(
379379
return nullptr;
380380
}
381381

382-
return MakeBaseObject<IntervalHistogram>(
382+
return MakeBaseObject<ELDHistogram>(
383383
env,
384384
obj,
385385
AsyncWrap::PROVIDER_ELDHISTOGRAM,
386386
options);
387387
}
388388

389-
void IntervalHistogram::PrepareCB(uv_prepare_t* handle) {
390-
IntervalHistogram* self = static_cast<IntervalHistogram*>(handle->data);
389+
void ELDHistogram::PrepareCB(uv_prepare_t* handle) {
390+
ELDHistogram* self = static_cast<ELDHistogram*>(handle->data);
391391
if (!self->enabled_) return;
392392
self->prepare_time_ = uv_hrtime();
393393
self->timeout_ = uv_backend_timeout(handle->loop);
394394
}
395395

396-
void IntervalHistogram::CheckCB(uv_check_t* handle) {
397-
IntervalHistogram* self =
398-
ContainerOf(&IntervalHistogram::check_handle_, handle);
396+
void ELDHistogram::CheckCB(uv_check_t* handle) {
397+
ELDHistogram* self =
398+
ContainerOf(&ELDHistogram::check_handle_, handle);
399399
if (!self->enabled_) return;
400400

401401
uint64_t check_time = uv_hrtime();
@@ -413,11 +413,11 @@ void IntervalHistogram::CheckCB(uv_check_t* handle) {
413413
self->check_time_ = check_time;
414414
}
415415

416-
void IntervalHistogram::MemoryInfo(MemoryTracker* tracker) const {
416+
void ELDHistogram::MemoryInfo(MemoryTracker* tracker) const {
417417
tracker->TrackField("histogram", histogram());
418418
}
419419

420-
void IntervalHistogram::OnStart(StartFlags flags) {
420+
void ELDHistogram::OnStart(StartFlags flags) {
421421
if (enabled_ || IsHandleClosing()) return;
422422
enabled_ = true;
423423
if (flags == StartFlags::RESET)
@@ -431,20 +431,20 @@ void IntervalHistogram::OnStart(StartFlags flags) {
431431
uv_unref(reinterpret_cast<uv_handle_t*>(&prepare_handle_));
432432
}
433433

434-
void IntervalHistogram::OnStop() {
434+
void ELDHistogram::OnStop() {
435435
if (!enabled_ || IsHandleClosing()) return;
436436
enabled_ = false;
437437
uv_check_stop(&check_handle_);
438438
uv_prepare_stop(&prepare_handle_);
439439
}
440440

441-
void IntervalHistogram::PrepareCloseCB(uv_handle_t* handle) {
442-
IntervalHistogram* self = static_cast<IntervalHistogram*>(handle->data);
441+
void ELDHistogram::PrepareCloseCB(uv_handle_t* handle) {
442+
ELDHistogram* self = static_cast<ELDHistogram*>(handle->data);
443443
uv_close(reinterpret_cast<uv_handle_t*>(&self->check_handle_),
444444
HandleWrap::OnClose);
445445
}
446446

447-
void IntervalHistogram::Close(Local<Value> close_callback) {
447+
void ELDHistogram::Close(Local<Value> close_callback) {
448448
if (IsHandleClosing()) return;
449449
OnStop();
450450
state_ = kClosing;
@@ -460,28 +460,28 @@ void IntervalHistogram::Close(Local<Value> close_callback) {
460460
PrepareCloseCB);
461461
}
462462

463-
void IntervalHistogram::Start(const FunctionCallbackInfo<Value>& args) {
464-
IntervalHistogram* histogram;
463+
void ELDHistogram::Start(const FunctionCallbackInfo<Value>& args) {
464+
ELDHistogram* histogram;
465465
ASSIGN_OR_RETURN_UNWRAP(&histogram, args.This());
466466
histogram->OnStart(args[0]->IsTrue() ? StartFlags::RESET : StartFlags::NONE);
467467
}
468468

469-
void IntervalHistogram::FastStart(Local<Value> receiver, bool reset) {
469+
void ELDHistogram::FastStart(Local<Value> receiver, bool reset) {
470470
TRACK_V8_FAST_API_CALL("histogram.start");
471-
IntervalHistogram* histogram;
471+
ELDHistogram* histogram;
472472
ASSIGN_OR_RETURN_UNWRAP(&histogram, receiver);
473473
histogram->OnStart(reset ? StartFlags::RESET : StartFlags::NONE);
474474
}
475475

476-
void IntervalHistogram::Stop(const FunctionCallbackInfo<Value>& args) {
477-
IntervalHistogram* histogram;
476+
void ELDHistogram::Stop(const FunctionCallbackInfo<Value>& args) {
477+
ELDHistogram* histogram;
478478
ASSIGN_OR_RETURN_UNWRAP(&histogram, args.This());
479479
histogram->OnStop();
480480
}
481481

482-
void IntervalHistogram::FastStop(Local<Value> receiver) {
482+
void ELDHistogram::FastStop(Local<Value> receiver) {
483483
TRACK_V8_FAST_API_CALL("histogram.stop");
484-
IntervalHistogram* histogram;
484+
ELDHistogram* histogram;
485485
ASSIGN_OR_RETURN_UNWRAP(&histogram, receiver);
486486
histogram->OnStop();
487487
}
@@ -650,7 +650,7 @@ HistogramImpl* HistogramImpl::FromJSObject(Local<Value> value) {
650650
}
651651

652652
std::unique_ptr<worker::TransferData>
653-
IntervalHistogram::CloneForMessaging() const {
653+
ELDHistogram::CloneForMessaging() const {
654654
return std::make_unique<HistogramBase::HistogramTransferData>(histogram());
655655
}
656656

src/histogram.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class HistogramBase final : public BaseObject, public HistogramImpl {
206206
static v8::CFunction fast_record_delta_;
207207
};
208208

209-
class IntervalHistogram final : public HandleWrap, public HistogramImpl {
209+
class ELDHistogram final : public HandleWrap, public HistogramImpl {
210210
public:
211211
enum InternalFields {
212212
kInternalFieldCount = std::max<uint32_t>(
@@ -223,11 +223,11 @@ class IntervalHistogram final : public HandleWrap, public HistogramImpl {
223223
static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
224224
Environment* env);
225225

226-
static BaseObjectPtr<IntervalHistogram> Create(
226+
static BaseObjectPtr<ELDHistogram> Create(
227227
Environment* env,
228228
const Histogram::Options& options);
229229

230-
IntervalHistogram(
230+
ELDHistogram(
231231
Environment* env,
232232
v8::Local<v8::Object> wrap,
233233
AsyncWrap::ProviderType type,
@@ -248,8 +248,8 @@ class IntervalHistogram final : public HandleWrap, public HistogramImpl {
248248
v8::Local<v8::Value>()) override;
249249

250250
void MemoryInfo(MemoryTracker* tracker) const override;
251-
SET_MEMORY_INFO_NAME(IntervalHistogram)
252-
SET_SELF_SIZE(IntervalHistogram)
251+
SET_MEMORY_INFO_NAME(ELDHistogram)
252+
SET_SELF_SIZE(ELDHistogram)
253253

254254
private:
255255
static void PrepareCB(uv_prepare_t* handle);

src/node_perf.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ void UvMetricsInfo(const FunctionCallbackInfo<Value>& args) {
280280

281281
void CreateELDHistogram(const FunctionCallbackInfo<Value>& args) {
282282
Environment* env = Environment::GetCurrent(args);
283-
BaseObjectPtr<IntervalHistogram> histogram =
284-
IntervalHistogram::Create(env, Histogram::Options { 1 });
283+
BaseObjectPtr<ELDHistogram> histogram =
284+
ELDHistogram::Create(env, Histogram::Options { 1 });
285285
args.GetReturnValue().Set(histogram->object());
286286
}
287287

@@ -398,7 +398,7 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
398398
registry->Register(SlowPerformanceNow);
399399
registry->Register(fast_performance_now);
400400
HistogramBase::RegisterExternalReferences(registry);
401-
IntervalHistogram::RegisterExternalReferences(registry);
401+
ELDHistogram::RegisterExternalReferences(registry);
402402
}
403403
} // namespace performance
404404
} // namespace node

0 commit comments

Comments
 (0)