mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
events: lazy load perf_hooks for EventTarget
PR-URL: https://github.com/nodejs/node/pull/33717 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Zeyu Yang <himself65@outlook.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
@@ -19,7 +19,6 @@ const {
|
||||
}
|
||||
} = require('internal/errors');
|
||||
|
||||
const perf_hooks = require('perf_hooks');
|
||||
const { customInspectSymbol } = require('internal/util');
|
||||
const { inspect } = require('util');
|
||||
|
||||
@@ -30,11 +29,19 @@ const kTarget = Symbol('kTarget');
|
||||
const kNewListener = Symbol('kNewListener');
|
||||
const kRemoveListener = Symbol('kRemoveListener');
|
||||
|
||||
// Lazy load perf_hooks to avoid the additional overhead on startup
|
||||
let perf_hooks;
|
||||
function lazyNow() {
|
||||
if (perf_hooks === undefined)
|
||||
perf_hooks = require('perf_hooks');
|
||||
return perf_hooks.performance.now();
|
||||
}
|
||||
|
||||
class Event {
|
||||
#type = undefined;
|
||||
#defaultPrevented = false;
|
||||
#cancelable = false;
|
||||
#timestamp = perf_hooks.performance.now();
|
||||
#timestamp = lazyNow();
|
||||
|
||||
// None of these are currently used in the Node.js implementation
|
||||
// of EventTarget because there is no concept of bubbling or
|
||||
|
||||
@@ -21,7 +21,6 @@ const expectedModules = new Set([
|
||||
'Internal Binding module_wrap',
|
||||
'Internal Binding native_module',
|
||||
'Internal Binding options',
|
||||
'Internal Binding performance',
|
||||
'Internal Binding process_methods',
|
||||
'Internal Binding report',
|
||||
'Internal Binding string_decoder',
|
||||
@@ -32,7 +31,6 @@ const expectedModules = new Set([
|
||||
'Internal Binding types',
|
||||
'Internal Binding url',
|
||||
'Internal Binding util',
|
||||
'NativeModule async_hooks',
|
||||
'NativeModule buffer',
|
||||
'NativeModule events',
|
||||
'NativeModule fs',
|
||||
@@ -50,7 +48,6 @@ const expectedModules = new Set([
|
||||
'NativeModule internal/fixed_queue',
|
||||
'NativeModule internal/fs/dir',
|
||||
'NativeModule internal/fs/utils',
|
||||
'NativeModule internal/histogram',
|
||||
'NativeModule internal/idna',
|
||||
'NativeModule internal/linkedlist',
|
||||
'NativeModule internal/modules/run_main',
|
||||
@@ -88,7 +85,6 @@ const expectedModules = new Set([
|
||||
'NativeModule internal/vm/module',
|
||||
'NativeModule internal/worker/js_transferable',
|
||||
'NativeModule path',
|
||||
'NativeModule perf_hooks',
|
||||
'NativeModule timers',
|
||||
'NativeModule url',
|
||||
'NativeModule util',
|
||||
|
||||
Reference in New Issue
Block a user