benchmark: add startup benchmark for loading public modules

Adding a new benchmark for testing the performance of loading
available public modules.

PR-URL: https://github.com/nodejs/node/pull/35816
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Joyee Cheung committed 2020-11-04 10:39:13 +08:00
1 parent fc8e3e2cdc
commit 38c15691eb
2 files changed
+51 -1

No files matched your search

+46
View File
@@ -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',
];
for (let i = 0; i < list.length; ++i) {
const item = list[i];
require(item);
}
+5 -1
View File
@@ -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']