GeezerVison is showing github.com — perf_hooks: do not expose SafeMap via Histogram wrapper · nodejs/node@f67b686
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/histogram.js +6-5Lines changed: 6 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | 'use strict'; | 2 | 2 |
| 3 | 3 | const { | | 4 | + Map, | | 5 | + MapPrototypeClear, | 4 | 6 | MapPrototypeEntries, | 5 | 7 | NumberIsNaN, | 6 | 8 | NumberMAX_SAFE_INTEGER, | 7 | 9 | ObjectFromEntries, | 8 | 10 | ReflectConstruct, | 9 | | - SafeMap, | 10 | 11 | Symbol, | 11 | 12 | } = primordials; | 12 | 13 |
| @@ -216,7 +217,7 @@ class Histogram { | 216 | 217 | get percentiles() { | 217 | 218 | if (!isHistogram(this)) | 218 | 219 | throw new ERR_INVALID_THIS('Histogram'); | 219 | | - this[kMap].clear(); | | 220 | + MapPrototypeClear(this[kMap]); | 220 | 221 | this[kHandle]?.percentiles(this[kMap]); | 221 | 222 | return this[kMap]; | 222 | 223 | } | @@ -228,7 +229,7 @@ class Histogram { | 228 | 229 | get percentilesBigInt() { | 229 | 230 | if (!isHistogram(this)) | 230 | 231 | throw new ERR_INVALID_THIS('Histogram'); | 231 | | - this[kMap].clear(); | | 232 | + MapPrototypeClear(this[kMap]); | 232 | 233 | this[kHandle]?.percentilesBigInt(this[kMap]); | 233 | 234 | return this[kMap]; | 234 | 235 | } | @@ -331,7 +332,7 @@ function ClonedHistogram(handle) { | 331 | 332 | function() { | 332 | 333 | markTransferMode(this, true, false); | 333 | 334 | this[kHandle] = handle; | 334 | | - this[kMap] = new SafeMap(); | | 335 | + this[kMap] = new Map(); | 335 | 336 | }, [], Histogram); | 336 | 337 | } | 337 | 338 |
| @@ -342,7 +343,7 @@ function ClonedRecordableHistogram(handle) { | 342 | 343 |
| 343 | 344 | markTransferMode(histogram, true, false); | 344 | 345 | histogram[kRecordable] = true; | 345 | | - histogram[kMap] = new SafeMap(); | | 346 | + histogram[kMap] = new Map(); | 346 | 347 | histogram[kHandle] = handle; | 347 | 348 | histogram.constructor = RecordableHistogram; | 348 | 349 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-perf-hooks-histogram.js +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | const common = require('../common'); | 4 | 4 |
| 5 | 5 | const { | | 6 | + deepStrictEqual, | 6 | 7 | ok, | 7 | 8 | strictEqual, | 8 | 9 | throws, | @@ -58,6 +59,10 @@ const { inspect } = require('util'); | 58 | 59 | strictEqual(h.percentileBigInt(1), 1n); | 59 | 60 | strictEqual(h.percentileBigInt(100), 1n); | 60 | 61 |
| | 62 | + deepStrictEqual(h.percentiles, new Map([[0, 1], [100, 1]])); | | 63 | + | | 64 | + deepStrictEqual(h.percentilesBigInt, new Map([[0, 1n], [100, 1n]])); | | 65 | + | 61 | 66 | const mc = new MessageChannel(); | 62 | 67 | mc.port1.onmessage = common.mustCall(({ data }) => { | 63 | 68 | strictEqual(h.min, 1); | |
|