1 |
import { createHistogram } from 'node:perf_hooks' |
|
2 |
|
31✔ |
3 |
class RecordableHistogram {
|
|
4 |
#histogram = createHistogram()
|
86✔ |
5 |
|
86✔ |
6 |
constructor() { |
|
7 |
Object.keys(this.#histogram.toJSON()) |
86✔ |
8 |
.filter(prop => typeof prop !== 'object') |
|
9 |
.forEach(prop => Object.defineProperty(this, prop, {
|
|
10 |
enumerable: true, |
602✔ |
11 |
get() { return this.#histogram[prop] } |
|
12 |
})) |
86✔ |
13 |
} |
86✔ |
14 |
|
86✔ |
15 |
record(value) { |
|
16 |
return this.#histogram.record(value) |
6,178✔ |
17 |
} |
6,178✔ |
18 |
|
86✔ |
19 |
recordDelta() { |
86✔ |
20 |
return this.#histogram.recordDelta() |
× |
21 |
} |
× |
22 |
|
86✔ |
23 |
reset() { |
86✔ |
24 |
return this.#histogram.reset() |
× |
25 |
} |
× |
26 |
|
86✔ |
27 |
toJSON() { |
|
28 |
return this.#histogram.toJSON() |
6,178✔ |
29 |
} |
6,178✔ |
30 |
} |
86✔ |
31 |
|
31✔ |
32 |
export default RecordableHistogram |
31✔ |