Skip to content

Commit

Permalink
benchmark: add startup benchmark for loading public modules
Browse files Browse the repository at this point in the history
Adding a new benchmark for testing the performance of loading
available public modules.

PR-URL: #35816
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
joyeecheung committed Nov 4, 2020
1 parent fc8e3e2 commit 38c1569
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
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',
];

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

0 comments on commit 38c1569

Please sign in to comment.