node/lib/perf_hooks.js
Joyee Cheung a75d4e2724
perf_hooks: refactor perf_hooks for snapshot building
- Move Performance and InternalPerformance to a new
  lib/internal/perf/performance.js
- Move now() getMilestoneTimestamp() into
  lib/internal/perf/utils.js
- Rename lib/internal/perf/perf.js to
  lib/internal/perf/performance_entry.js
- Refresh time origin at startup (this means the
  time origins could differ between snapshot building
  time and snapshot creation time)

PR-URL: https://github.com/nodejs/node/pull/38971
Refs: https://github.com/nodejs/node/issues/35711
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-06-28 16:20:12 +08:00

35 lines
823 B
JavaScript

'use strict';
const {
ObjectDefineProperty,
} = primordials;
const {
constants,
} = internalBinding('performance');
const { PerformanceEntry } = require('internal/perf/performance_entry');
const { PerformanceObserver } = require('internal/perf/observe');
const { PerformanceMark } = require('internal/perf/usertiming');
const { InternalPerformance } = require('internal/perf/performance');
const {
createHistogram
} = require('internal/histogram');
const monitorEventLoopDelay = require('internal/perf/event_loop_delay');
module.exports = {
PerformanceEntry,
PerformanceMark,
PerformanceObserver,
monitorEventLoopDelay,
createHistogram,
performance: new InternalPerformance(),
};
ObjectDefineProperty(module.exports, 'constants', {
configurable: false,
enumerable: true,
value: constants
});