Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

benchmark: add startup benchmark for loading public modules #35816

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions benchmark/fixtures/require-builtins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
'use strict';

const list = [
'async_hooks',
'assert',
'buffer',
'child_process',
'console',
'constants',
'crypto',
'cluster',
'dgram',
'dns',
'domain',
'events',
'fs',
'http',
'http2',
'https',
'inspector',
'module',
'net',
'os',
'path',
'perf_hooks',
'process',
'punycode',
'querystring',
'readline',
'repl',
'stream',
'string_decoder',
'timers',
'tls',
'trace_events',
'tty',
'url',
'util',
'vm',
'zlib',
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcode was likely missed some modules, just like v8, worker_threads here.

Can we directly use require('module').builtinModules ?

Copy link
Member Author

@joyeecheung joyeecheung Oct 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ZYSzys That way we may not be able to get fair results on different versions of Node.js (some of them may have more modules)


for (let i = 0; i < list.length; ++i) {
const item = list[i];
require(item);
}
6 changes: 5 additions & 1 deletion benchmark/misc/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ let Worker; // Lazy loaded in main

const bench = common.createBenchmark(main, {
dur: [1],
script: ['benchmark/fixtures/require-cachable', 'test/fixtures/semicolon'],
script: [
'benchmark/fixtures/require-builtins',
'benchmark/fixtures/require-cachable',
'test/fixtures/semicolon',
],
mode: ['process', 'worker']
}, {
flags: ['--expose-internals']
Expand Down