mirror of
https://github.com/nodejs/node.git
synced 2026-10-10 18:59:49 -04:00
The current recordable `Histogram` does not maintain any sense of time. Samples accumulate indefinitely as they are collected. This implements a relatively simple sliding-window mechanism that can be count or time based. The key benefit is that the window remains fixed/bounded while samples are recorded. The sliding window is chunk based. Internally, it maintains a ring buffer of a fixed number of individual histograms. When snapshot() is called, those are materialized into a single combined histogram. As the window slides, older chunks (and all of the samples they hold) are dropped from the window so the window drops however many samples happened to be in that chunk. This does mean that precision of the window is determined by the chunk size. Signed-off-by: James M Snell <jasnell@gmail.com> Assisted-by: Opencode PR-URL: https://github.com/nodejs/node/pull/65825 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
59 lines
1.3 KiB
JavaScript
59 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
const {
|
|
ObjectDefineProperty,
|
|
} = primordials;
|
|
|
|
const {
|
|
constants,
|
|
} = internalBinding('performance');
|
|
|
|
const { PerformanceEntry } = require('internal/perf/performance_entry');
|
|
const { PerformanceResourceTiming } = require('internal/perf/resource_timing');
|
|
const {
|
|
PerformanceObserver,
|
|
PerformanceObserverEntryList,
|
|
} = require('internal/perf/observe');
|
|
const {
|
|
PerformanceMark,
|
|
PerformanceMeasure,
|
|
} = require('internal/perf/usertiming');
|
|
const {
|
|
Performance,
|
|
performance,
|
|
} = require('internal/perf/performance');
|
|
|
|
const {
|
|
createHistogram,
|
|
createSlidingWindowHistogram,
|
|
importHistogram,
|
|
} = require('internal/histogram');
|
|
|
|
const monitorEventLoopDelay = require('internal/perf/event_loop_delay');
|
|
const { eventLoopUtilization } = require('internal/perf/event_loop_utilization');
|
|
const timerify = require('internal/perf/timerify');
|
|
|
|
module.exports = {
|
|
Performance,
|
|
PerformanceEntry,
|
|
PerformanceMark,
|
|
PerformanceMeasure,
|
|
PerformanceObserver,
|
|
PerformanceObserverEntryList,
|
|
PerformanceResourceTiming,
|
|
monitorEventLoopDelay,
|
|
eventLoopUtilization,
|
|
timerify,
|
|
createHistogram,
|
|
createSlidingWindowHistogram,
|
|
importHistogram,
|
|
performance,
|
|
};
|
|
|
|
ObjectDefineProperty(module.exports, 'constants', {
|
|
__proto__: null,
|
|
configurable: false,
|
|
enumerable: true,
|
|
value: constants,
|
|
});
|