FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

events: lazy load perf_hooks for EventTarget by jasnell · Pull Request #33717 · nodejs/node · GitHub

/ node Public
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
11 changes: 9 additions & 2 deletions lib/internal/event_target.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const {
}
} = require('internal/errors');

const perf_hooks = require('perf_hooks');
const { customInspectSymbol } = require('internal/util');
const { inspect } = require('util');

Expand All @@ -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
Expand Down
4 changes: 0 additions & 4 deletions test/parallel/test-bootstrap-modules.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,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',
Expand All @@ -31,7 +30,6 @@ const expectedModules = new Set([
'Internal Binding types',
'Internal Binding url',
'Internal Binding util',
'NativeModule async_hooks',
'NativeModule buffer',
'NativeModule events',
'NativeModule fs',
Expand All @@ -49,7 +47,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',
Expand Down Expand Up @@ -86,7 +83,6 @@ const expectedModules = new Set([
'NativeModule internal/validators',
'NativeModule internal/vm/module',
'NativeModule path',
'NativeModule perf_hooks',
'NativeModule timers',
'NativeModule url',
'NativeModule util',
Expand Down

Back | FazBrowse Home | New Git URL