Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2020-10-26 18:54:41 +0300
committerJoyee Cheung <joyeec9h3@gmail.com>2020-11-04 05:39:13 +0300
commit38c15691eb8070b19a04dc572ac09dcb9155f3f1 (patch)
tree7281c3b74070ffbfc876e9e37ef48fbdb1567d13 /benchmark
parentfc8e3e2cdc521978351de257030db0076d79e0ab (diff)
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>
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/fixtures/require-builtins.js46
-rw-r--r--benchmark/misc/startup.js6
2 files changed, 51 insertions, 1 deletions
diff --git a/benchmark/fixtures/require-builtins.js b/benchmark/fixtures/require-builtins.js
new file mode 100644
index 00000000000..a100e9efd0c
--- /dev/null
+++ b/benchmark/fixtures/require-builtins.js
@@ -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);
+}
diff --git a/benchmark/misc/startup.js b/benchmark/misc/startup.js
index da24ee65199..dea5a31753f 100644
--- a/benchmark/misc/startup.js
+++ b/benchmark/misc/startup.js
@@ -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']