Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions lib/internal/histogram.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
'use strict';

const {
Map,
MapPrototypeClear,
MapPrototypeEntries,
NumberIsNaN,
NumberMAX_SAFE_INTEGER,
ObjectFromEntries,
ReflectConstruct,
SafeMap,
Symbol,
} = primordials;

Expand Down Expand Up @@ -216,7 +217,7 @@ class Histogram {
get percentiles() {
if (!isHistogram(this))
throw new ERR_INVALID_THIS('Histogram');
this[kMap].clear();
MapPrototypeClear(this[kMap]);
this[kHandle]?.percentiles(this[kMap]);
return this[kMap];
}
Expand All @@ -228,7 +229,7 @@ class Histogram {
get percentilesBigInt() {
if (!isHistogram(this))
throw new ERR_INVALID_THIS('Histogram');
this[kMap].clear();
MapPrototypeClear(this[kMap]);
this[kHandle]?.percentilesBigInt(this[kMap]);
return this[kMap];
}
Expand Down Expand Up @@ -331,7 +332,7 @@ function ClonedHistogram(handle) {
function() {
markTransferMode(this, true, false);
this[kHandle] = handle;
this[kMap] = new SafeMap();
this[kMap] = new Map();
}, [], Histogram);
}

Expand All @@ -342,7 +343,7 @@ function ClonedRecordableHistogram(handle) {

markTransferMode(histogram, true, false);
histogram[kRecordable] = true;
histogram[kMap] = new SafeMap();
histogram[kMap] = new Map();
histogram[kHandle] = handle;
histogram.constructor = RecordableHistogram;

Expand Down
5 changes: 5 additions & 0 deletions test/parallel/test-perf-hooks-histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const common = require('../common');

const {
deepStrictEqual,
ok,
strictEqual,
throws,
Expand Down Expand Up @@ -58,6 +59,10 @@ const { inspect } = require('util');
strictEqual(h.percentileBigInt(1), 1n);
strictEqual(h.percentileBigInt(100), 1n);

deepStrictEqual(h.percentiles, new Map([[0, 1], [100, 1]]));

deepStrictEqual(h.percentilesBigInt, new Map([[0, 1n], [100, 1n]]));

const mc = new MessageChannel();
mc.port1.onmessage = common.mustCall(({ data }) => {
strictEqual(h.min, 1);
Expand Down
Loading