From 2ce22442f6b5905280ff9fc3427b9422cda94500 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Mon, 26 Oct 2020 23:54:41 +0800 Subject: [PATCH] benchmark: add startup benchmark for loading public modules Adding a new benchmark for testing the performance of loading available public modules. --- benchmark/fixtures/require-builtins.js | 46 ++++++++++++++++++++++++++ benchmark/misc/startup.js | 6 +++- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 benchmark/fixtures/require-builtins.js diff --git a/benchmark/fixtures/require-builtins.js b/benchmark/fixtures/require-builtins.js new file mode 100644 index 00000000000000..a100e9efd0cae5 --- /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 da24ee65199077..dea5a31753f8fe 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']