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

v11.14.0 proposal #27163

Merged
merged 133 commits into from
Apr 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
62f9049
src: refactor node options parsers to mitigate MSVC bug
refack Feb 23, 2019
e6c1ad5
src: fix warnings around node_options
refack Feb 25, 2019
63e7cc7
src: forbid access to CLI options before bootstrapping is done
joyeecheung Mar 6, 2019
ab70c96
src: refactor coverage connection
joyeecheung Mar 8, 2019
03bd649
test: show stderr on v8 coverage test failures
joyeecheung Mar 8, 2019
d4f9509
process: delay process.argv[0] and process.argv0 handling
joyeecheung Mar 8, 2019
75c5d9c
process: create legacy process properties during pre-execution
joyeecheung Mar 8, 2019
5a29a94
http: reduce usage of public util
ZYSzys Mar 9, 2019
c51cc9e
src: apply clang-tidy rule modernize-make-unique
gengjiawen Mar 7, 2019
7671a65
embedding: refactor public `ArrayBufferAllocator` API
addaleax Mar 8, 2019
5e64acd
embedding: make `NewIsolate()` API more flexible
addaleax Mar 8, 2019
1b45704
inspector: patch C++ debug options instead of process._breakFirstLine
joyeecheung Mar 11, 2019
169f3f7
util: require `isNativeError` from internalBinding
ZYSzys Mar 19, 2019
21486e5
util: extract uncurryThis function for reuse
ZYSzys Mar 19, 2019
4defe47
child_process: reduce internal usage of public require of util
toshi1127 Mar 19, 2019
44450ef
worker: remove usage of require('util')
toshi1127 Mar 20, 2019
b24e45a
timers: deprecate active() and _unrefActive()
Fishrock123 Mar 18, 2019
5d9f819
worker: remove usage of require('util') in worker_thread.js
toshi1127 Mar 20, 2019
bb9f1cc
fs: reduce usage of require('util')
toshi1127 Mar 25, 2019
a03552d
process: handle --expose-internals during pre-execution
joyeecheung Mar 18, 2019
e43dbaa
console: remove unreachable code
Trott Mar 25, 2019
80e845e
test: add test about unencrypted PKCS#8 private key for RSA
sasurau4 Mar 25, 2019
c1def07
src: delete unreachable code in heap_utils.cc
gengjiawen Mar 20, 2019
ea7e2c0
src: tidy up include headers in env.cc
gengjiawen Mar 20, 2019
c824127
src: delete unused field in class ModuleWrap
gengjiawen Mar 20, 2019
c969731
src: use deleted function for class BaseObject
gengjiawen Mar 20, 2019
6bfb17f
src: fix task release in cares_wrap.cc
gengjiawen Mar 20, 2019
0427354
src: delete useless code in cares_wrap.cc
gengjiawen Mar 20, 2019
a1cf745
test: refactor path parse test
BridgeAR Mar 26, 2019
bd006e1
path: fix win32 parse regression
BridgeAR Mar 26, 2019
1b08e62
util: improve proxy inspection
BridgeAR Mar 26, 2019
682b410
worker: allow execArgv and eval in combination
addaleax Mar 8, 2019
c756b84
errors: make range mandatory in ERR_OUT_OF_RANGE
BridgeAR Mar 26, 2019
17bff5c
doc: remove reference to "credentials object"
sam-github Mar 25, 2019
a821a96
doc: correct typo: cert.issuerCertificate
srl295 Mar 26, 2019
98552f3
crypto: allow undefined for saltLength and padding
tniessen Mar 26, 2019
de93737
benchmark: remove unused field in class BenchmarkProgress
gengjiawen Mar 26, 2019
25d5198
doc: change links to https in benchmark guide
gengjiawen Mar 26, 2019
5512ecb
benchmark: tidy up eslint ignore in foreach-bench.js
gengjiawen Mar 26, 2019
2ef1bd9
test: do not require flags when executing a file
BridgeAR Mar 22, 2019
edad9af
test: move hasCrypto check
BridgeAR Mar 27, 2019
fd6381b
test: remove test-path-parse-6229.js from known issues
BridgeAR Mar 26, 2019
1aa6e99
util: fix map entries inspection
BridgeAR Mar 26, 2019
b62739c
path: remove dead code
BridgeAR Mar 26, 2019
d3c1de3
dns: remove dns.promises experimental warning
cjihrig Mar 11, 2019
ac12109
dns: make dns.promises enumerable
cjihrig Mar 27, 2019
4a7a84a
doc: move dns.promises to stable status
cjihrig Mar 27, 2019
d76c30c
doc: add note about mkdtemp() platform differences
cjihrig Mar 27, 2019
9330d7e
test: add known_issues test for fs.copyFile()
Trott Mar 27, 2019
769d12c
build: add a `Prepare ccache` job in Travis
richardlau Mar 29, 2019
6cbd6b5
build: fix skipping of flaky tests on Travis
richardlau Mar 28, 2019
e776b01
src: do not call into JS in the maxAsyncCallStackDepthChanged interrupt
joyeecheung Mar 26, 2019
760d089
inspector: display error when ToggleAsyncHook fails
joyeecheung Mar 22, 2019
28efecc
doc: remove "How is an LTS release cut?" section
Trott Mar 28, 2019
8798db3
url: add ws: and wss: to slashedProtocol set
lpinca Mar 27, 2019
17cc117
doc: update changelog for v10.x LTS
BethGriggs Mar 26, 2019
0f615d4
util: add subclass and null prototype support for errors in inspect
BridgeAR Mar 26, 2019
0aea4d1
benchmark,lib: change var to const
BridgeAR Mar 26, 2019
7fe43bd
build: remove unused label from vcbuild.bat
bnoordhuis Mar 25, 2019
dc9ce86
tools: update dependencies in lint-md-cli-rollup
watilde Mar 24, 2019
e5181f8
test: simplify for loop in test-buffer-zero-fill-cli.js
juanarbol Mar 20, 2019
78fad32
readline: replace quadratic regex with linear one
Hakerh400 Mar 19, 2019
d3840bc
src: allow per-Environment set of env vars
addaleax Mar 13, 2019
729e2f2
src: implement generic backend for process.env
addaleax Mar 13, 2019
8bd7909
worker: use copy of process.env
addaleax Feb 22, 2019
3c92926
module: simpler esm loading
BridgeAR Mar 29, 2019
ea47189
stream: do not unconditionally call `_read()` on `resume()`
addaleax Mar 28, 2019
b64b223
build,win: silence MSVC warning C4129 for V8
refack Mar 30, 2019
2396743
child_process: doc deprecate ChildProcess._channel
cjihrig Mar 29, 2019
7a39196
doc: change code lang and update it with latest Node.js
gengjiawen Mar 29, 2019
fbdead7
src: add missing uv_fs_req_cleanup()
cjihrig Mar 30, 2019
06dce39
test: fix error code typo
cjihrig Mar 31, 2019
d0ee1a3
src: fix warning on mismatched fn signature
sam-github Mar 27, 2019
8258f07
test: remove unused triggerAsyncId param in test
juanarbol Mar 20, 2019
7cbe121
tools: update ESLint to 5.16.0
cjihrig Mar 30, 2019
57207e7
doc: list when promiseResolve hook was added to async_hooks
watson Mar 29, 2019
0b94aec
doc: add information about modules cache behavior
BridgeAR Mar 28, 2019
64a74d5
doc: move "Prints: ..." under the code
simon300000 Mar 31, 2019
96e429a
dns: refactor lib/internal/dns/utils.js
Trott Mar 30, 2019
a0b0e42
test: add IPv6 brackets but no port to test-dns
Trott Mar 30, 2019
b766c06
build,meta: tweak Travis config
refack Mar 28, 2019
5102d69
src: remove internal includes from node_crypto.h
sam-github Mar 28, 2019
4c96ef7
doc: improve the doc of the 'information' event
lpinca Mar 30, 2019
687348a
test: move test that creates 1Gb file to pummel
Trott Apr 2, 2019
ccd3b74
fs: remove experimental warning for fs.promises
addaleax Mar 11, 2019
5945cf0
tools: fix `test.py --time`
richardlau Mar 30, 2019
38da9be
test: remove test-trace-events-api-worker-disabled from flaky
Trott Mar 30, 2019
054cf7b
src: replace c-style cast
gengjiawen Mar 24, 2019
5fdee11
doc: remove description duplication in buffer.md
vsemozhetbyt Mar 30, 2019
fd3b031
doc: fix possible typo in buffer.md
vsemozhetbyt Mar 31, 2019
944ce7b
doc: add missing types in buffer.md
vsemozhetbyt Mar 31, 2019
5fd4053
doc: unify number/integer types in buffer.md
vsemozhetbyt Mar 31, 2019
3a35d8a
doc: fix error notes in `Buffer.from()` variants
vsemozhetbyt Mar 30, 2019
f9ef9eb
doc: add note about Buffer octets integer coercion
vsemozhetbyt Mar 31, 2019
ea75d43
doc: mark optional parameters in buffer.md
vsemozhetbyt Mar 31, 2019
19ccee0
doc: add notes about negative offsets in buffer.md
vsemozhetbyt Mar 31, 2019
221bcfb
doc: unify periods in comments in buffer.md
vsemozhetbyt Mar 30, 2019
00eef26
doc: unify link formatting in buffer.md
vsemozhetbyt Mar 31, 2019
e40bfd8
util: `inspect()` should not exceed `breakLength`
BridgeAR Mar 26, 2019
a318cbc
src: elevate v8::Task namespace
juanarbol Mar 21, 2019
addc73a
path: refactor for less indentation
BridgeAR Mar 26, 2019
316372c
doc: remove old system_errors
JungMinu Mar 29, 2019
fec9f76
process: run RunBootstrapping in CreateEnvironment
joyeecheung Mar 19, 2019
d3c1481
report: add cwd to report
cjihrig Mar 31, 2019
0fc5dcc
doc: remove unnecessary intro in governance doc
Trott Mar 31, 2019
26af6fb
doc: document the 'pause' and 'resume' events
lpinca Mar 29, 2019
0ac41fc
stream: make Symbol.asyncIterator support stable
mcollina Mar 29, 2019
6d39460
readline: make Symbol.asyncIterator support stable
mcollina Apr 1, 2019
58da879
module: fix repl require calling the same file again
BridgeAR Mar 26, 2019
3fce303
test: make module test pass with NODE_PENDING_DEPRECATION
addaleax Mar 30, 2019
3e4c03d
deps: update nghttp2 to 1.37.0
gengjiawen Mar 29, 2019
438bc52
src: apply clang-tidy rule bugprone-incorrect-roundings
gengjiawen Mar 24, 2019
1bbe5b3
process: store argv in Environment
joyeecheung Mar 19, 2019
a58437d
build: only emit download ICU warnings once
richardlau Mar 31, 2019
7547d8e
doc: fix default maxBuffer size
koh110 Sep 17, 2018
2f1da92
meta: move ofrobots to TSC emeritus
ofrobots Apr 3, 2019
a21bee7
src: use sizeof(var) instead of sizeof(type)
bnoordhuis Apr 1, 2019
c62b1a2
benchmark: add new module loading benchmarks
BridgeAR Jan 2, 2019
4c7a2f1
benchmark: improve module-loader benchmark
BridgeAR Mar 28, 2019
cdb0d84
module: inline try catch
BridgeAR Mar 28, 2019
8f6921e
module: add path to the module object
BridgeAR Mar 28, 2019
5917f4d
module: add extra caching layer
BridgeAR Mar 28, 2019
36714e1
buffer: fix concat error message
BridgeAR Apr 2, 2019
cee079f
deps: add ARM64 Windows support in openssl
shigeki Feb 23, 2019
ddf7477
deps: add ARM64 Windows configurations in openssl
jkunkee Mar 8, 2019
038b778
querystring: simplify stringify method
ZYSzys Mar 27, 2019
70d9f32
src: prevent crash in TTYWrap::Initialize
Hakerh400 Mar 21, 2019
066cd60
crypto: fix crash of encrypted private key export without cipher
panva Apr 1, 2019
d688a93
async_hooks: minor cleanup and improvements
apapirovski Mar 31, 2019
b502873
build: fix inspector dependency resolution
bnoordhuis Mar 31, 2019
a00d840
crypto: fix crash of encrypted private key export without cipher
panva Apr 1, 2019
75e8377
doc: assign missed deprecation code
richardlau Apr 9, 2019
cd026f8
2019-04-11, Version 11.14.0 (Current)
BethGriggs Apr 9, 2019
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
54 changes: 44 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,57 @@
language: cpp
cache: ccache
os: linux
dist: xenial
matrix:
jobs:
include:
- name: "First commit message adheres to guidelines at <a href=\"https://goo.gl/p2fr5Q\">https://goo.gl/p2fr5Q</a>"
- stage: "Lint and Compile"
name: "First commit message adheres to guidelines at <a href=\"https://goo.gl/p2fr5Q\">https://goo.gl/p2fr5Q</a>"
if: type = pull_request
language: node_js
node_js: "node"
script:
- if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then
bash -x tools/lint-pr-commit-message.sh ${TRAVIS_PULL_REQUEST};
fi

- name: "Linter"
language: node_js
node_js: "node"
env:
- NODE=$(which node)
install:
- make lint-py-build || true
script:
- NODE=$(which node) make lint-ci

- name: "Compile V8"
language: cpp
cache: ccache
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-6
install:
- CC='ccache gcc-6' CXX='ccache g++-6' ./configure
script:
- CC='ccache gcc-6' CXX='ccache g++-6' make -j2 -C out V=1 v8

- name: "Compile Node.js"
language: cpp
cache: ccache
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-6
install:
- CC='ccache gcc-6' CXX='ccache g++-6' ./configure
script:
- make lint
- name: "Test Suite"
- CC='ccache gcc-6' CXX='ccache g++-6' make -j2 V=1

- stage: "Tests"
name: "Test Suite"
language: cpp
cache: ccache
addons:
apt:
sources:
Expand All @@ -29,6 +61,8 @@ matrix:
install:
- export CC='ccache gcc-6' CXX='ccache g++-6' JOBS=2
- ./configure
- make -j2 V=
# We already have a compile log in the above job
- make -j2 > /dev/null
- make -j1 build-addons build-js-native-api-tests build-node-api-tests > /dev/null
script:
- PARALLEL_ARGS='--flaky-tests=skip' make -j1 test
- JOBS=2 FLAKY_TESTS=skip make -s -j1 V= test-ci | grep -F -e "---" -e "..." -v
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ release.
<table>
<tr>
<th title="Current"><a href="doc/changelogs/CHANGELOG_V11.md">11</a><sup>Current</sup></th>
<th title="Current"><a href="doc/changelogs/CHANGELOG_V10.md">10</a><sup>Current</sup></th>
<th title="LTS Until 2021-04"><a href="doc/changelogs/CHANGELOG_V10.md">10</a><sup>LTS</sup></th>
<th title="LTS Until 2019-12"><a href="doc/changelogs/CHANGELOG_V8.md">8</a><sup>LTS</sup></th>
<th title="LTS Until 2019-04"><a href="doc/changelogs/CHANGELOG_V6.md">6</a><sup>LTS</sup></th>
</tr>
<tr>
<td valign="top">
<b><a href="doc/changelogs/CHANGELOG_V11.md#11.13.0">11.13.0</a></b><br/>
<b><a href="doc/changelogs/CHANGELOG_V11.md#11.14.0">11.14.0</a></b><br/>
<a href="doc/changelogs/CHANGELOG_V11.md#11.13.0">11.13.0</a><br/>
<a href="doc/changelogs/CHANGELOG_V11.md#11.12.0">11.12.0</a><br/>
<a href="doc/changelogs/CHANGELOG_V11.md#11.11.0">11.11.0</a><br/>
<a href="doc/changelogs/CHANGELOG_V11.md#11.10.1">11.10.1</a><br/>
Expand Down
10 changes: 0 additions & 10 deletions COLLABORATOR_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@
- [I Made a Mistake](#i-made-a-mistake)
- [Long Term Support](#long-term-support)
- [What is LTS?](#what-is-lts)
- [How does LTS work?](#how-does-lts-work)
- [Landing semver-minor commits in LTS](#landing-semver-minor-commits-in-lts)
- [How are LTS Branches Managed?](#how-are-lts-branches-managed)
- [How can I help?](#how-can-i-help)
- [How is an LTS release cut?](#how-is-an-lts-release-cut)
* [Who to CC in the issue tracker](#who-to-cc-in-the-issue-tracker)

This document explains how Collaborators manage the Node.js project.
Expand Down Expand Up @@ -681,13 +678,6 @@ label.
Attach the appropriate `lts-watch-` label to any PR that may impact an LTS
release.

#### How is an LTS release cut?

When the LTS working group determines that a new LTS release is required,
selected commits will be picked from the staging branch to be included in the
release. This process of making a release will be a collaboration between the
LTS working group and the Release team.

## Who to CC in the issue tracker

| Subsystem | Maintainers |
Expand Down
4 changes: 0 additions & 4 deletions GOVERNANCE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Node.js Project Governance

The Node.js project is governed by its Collaborators, including a Technical
Steering Committee (TSC) which is responsible for high-level guidance of the
project.

<!-- TOC -->

- [Collaborators](#collaborators)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ For information about the governance of the Node.js project, see
**Michael Dawson** &lt;michael_dawson@ca.ibm.com&gt; (he/him)
* [MylesBorins](https://github.com/MylesBorins) -
**Myles Borins** &lt;myles.borins@gmail.com&gt; (he/him)
* [ofrobots](https://github.com/ofrobots) -
**Ali Ijaz Sheikh** &lt;ofrobots@google.com&gt; (he/him)
* [rvagg](https://github.com/rvagg) -
**Rod Vagg** &lt;rod@vagg.org&gt;
* [targos](https://github.com/targos) -
Expand Down Expand Up @@ -226,6 +224,8 @@ For information about the governance of the Node.js project, see
**Brian White** &lt;mscdex@mscdex.net&gt;
* [nebrius](https://github.com/nebrius) -
**Bryan Hughes** &lt;bryan@nebri.us&gt;
* [ofrobots](https://github.com/ofrobots) -
**Ali Ijaz Sheikh** &lt;ofrobots@google.com&gt; (he/him)
* [orangemocha](https://github.com/orangemocha) -
**Alexis Campailla** &lt;orangemocha@nodejs.org&gt;
* [piscisaureus](https://github.com/piscisaureus) -
Expand Down
1 change: 0 additions & 1 deletion benchmark/_benchmark_progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class BenchmarkProgress {
// Number of times each file will be run (roughly).
this.runsPerFile = queue.length / benchmarks.length;
this.currentFile = ''; // Filename of current benchmark.
this.currentFileConfig; // Configurations for current file
// Number of configurations already run for the current file.
this.completedConfig = 0;
// Total number of configurations for the current file
Expand Down
10 changes: 4 additions & 6 deletions benchmark/es/foreach-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@ function useFor(n, items, count) {
bench.start();
for (var i = 0; i < n; i++) {
for (var j = 0; j < count; j++) {
/* eslint-disable no-unused-vars */
// eslint-disable-next-line no-unused-vars
const item = items[j];
/* esline-enable no-unused-vars */
}
}
bench.end(n);
}

function useForOf(n, items) {
var item;
bench.start();
for (var i = 0; i < n; i++) {
for (item of items) {}
// eslint-disable-next-line no-unused-vars
for (const item of items) {}
}
bench.end(n);
}
Expand All @@ -33,9 +32,8 @@ function useForIn(n, items) {
bench.start();
for (var i = 0; i < n; i++) {
for (var j in items) {
/* eslint-disable no-unused-vars */
// eslint-disable-next-line no-unused-vars
const item = items[j];
/* esline-enable no-unused-vars */
}
}
bench.end(n);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/fs/readfile-partitioned.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function main(conf) {
fs.writeFileSync(filename, data);
data = null;

var zipData = Buffer.alloc(1024, 'a');
const zipData = Buffer.alloc(1024, 'a');

var reads = 0;
var zips = 0;
Expand Down
2 changes: 1 addition & 1 deletion benchmark/fs/write-stream-throughput.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function main({ dur, encodingType, size }) {
var started = false;
var ended = false;

var f = fs.createWriteStream(filename);
const f = fs.createWriteStream(filename);
f.on('drain', write);
f.on('open', write);
f.on('close', done);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/http/_chunky_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function main({ len, n }) {
const add = 11;
var count = 0;
const PIPE = process.env.PIPE_NAME;
var socket = net.connect(PIPE, () => {
const socket = net.connect(PIPE, () => {
bench.start();
WriteHTTPHeaders(socket, 1, len);
socket.setEncoding('utf8');
Expand Down
4 changes: 1 addition & 3 deletions benchmark/http/http_server_for_chunky_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ process.env.PIPE_NAME = PIPE;

tmpdir.refresh();

var server;

server = http.createServer((req, res) => {
const server = http.createServer((req, res) => {
const headers = {
'content-type': 'text/plain',
'content-length': '2'
Expand Down
2 changes: 1 addition & 1 deletion benchmark/http/set-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const c = 50;
// setHeaderWH: setHeader(...), writeHead(status, ...)
function main({ res }) {
process.env.PORT = PORT;
var server = require('../fixtures/simple-http-server.js')
const server = require('../fixtures/simple-http-server.js')
.listen(PORT)
.on('listening', () => {
const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`;
Expand Down
2 changes: 1 addition & 1 deletion benchmark/http/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const bench = common.createBenchmark(main, {
});

function main({ type, len, chunks, c, chunkedEnc, res }) {
var server = require('../fixtures/simple-http-server.js')
const server = require('../fixtures/simple-http-server.js')
.listen(common.PORT)
.on('listening', () => {
const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`;
Expand Down
2 changes: 1 addition & 1 deletion benchmark/http/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const resData = 'HTTP/1.1 101 Web Socket Protocol Handshake\r\n' +
'\r\n\r\n';

function main({ n }) {
var server = require('../fixtures/simple-http-server.js')
const server = require('../fixtures/simple-http-server.js')
.listen(common.PORT)
.on('listening', () => {
bench.start();
Expand Down
51 changes: 51 additions & 0 deletions benchmark/module/module-loader-deep.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use strict';
const fs = require('fs');
const path = require('path');
const common = require('../common.js');

const tmpdir = require('../../test/common/tmpdir');
const benchmarkDirectory = path.join(tmpdir.path, 'nodejs-benchmark-module');

const bench = common.createBenchmark(main, {
ext: ['', '.js'],
files: [1e3],
cache: ['true', 'false']
});

function main({ ext, cache, files }) {
tmpdir.refresh();
fs.mkdirSync(benchmarkDirectory);
fs.writeFileSync(
`${benchmarkDirectory}/a.js`,
'module.exports = {};'
);
for (var i = 0; i <= files; i++) {
fs.mkdirSync(`${benchmarkDirectory}/${i}`);
fs.writeFileSync(
`${benchmarkDirectory}/${i}/package.json`,
'{"main": "index.js"}'
);
fs.writeFileSync(
`${benchmarkDirectory}/${i}/index.js`,
`require('../a${ext}');`
);
}

measureDir(cache === 'true', files);

tmpdir.refresh();
}

function measureDir(cache, files) {
var i;
if (cache) {
for (i = 0; i <= files; i++) {
require(`${benchmarkDirectory}/${i}`);
}
}
bench.start();
for (i = 0; i <= files; i++) {
require(`${benchmarkDirectory}/${i}`);
}
bench.end(files);
}
60 changes: 28 additions & 32 deletions benchmark/module/module-loader.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
'use strict';
const fs = require('fs');
const path = require('path');
const { builtinModules } = require('module');
const common = require('../common.js');

const tmpdir = require('../../test/common/tmpdir');
const benchmarkDirectory = path.join(tmpdir.path, 'nodejs-benchmark-module');
let benchmarkDirectory = path.join(tmpdir.path, 'nodejs-benchmark-module');

// Filter all irregular modules.
const otherModules = builtinModules.filter((name) => !/\/|^_|^sys/.test(name));

const bench = common.createBenchmark(main, {
n: [5e4],
fullPath: ['true', 'false'],
useCache: ['true', 'false']
name: ['', '/', '/index.js'],
dir: ['rel', 'abs'],
files: [5e2],
n: [1, 1e3],
cache: ['true', 'false']
});

function main({ n, fullPath, useCache }) {
function main({ n, name, cache, files, dir }) {
tmpdir.refresh();
try { fs.mkdirSync(benchmarkDirectory); } catch {}
for (var i = 0; i <= n; i++) {
fs.mkdirSync(benchmarkDirectory);
for (var i = 0; i <= files; i++) {
fs.mkdirSync(`${benchmarkDirectory}${i}`);
fs.writeFileSync(
`${benchmarkDirectory}${i}/package.json`,
Expand All @@ -27,38 +33,28 @@ function main({ n, fullPath, useCache }) {
);
}

if (fullPath === 'true')
measureFull(n, useCache === 'true');
else
measureDir(n, useCache === 'true');
if (dir === 'rel')
benchmarkDirectory = path.relative(__dirname, benchmarkDirectory);

tmpdir.refresh();
}
measureDir(n, cache === 'true', files, name);

function measureFull(n, useCache) {
var i;
if (useCache) {
for (i = 0; i <= n; i++) {
require(`${benchmarkDirectory}${i}/index.js`);
}
}
bench.start();
for (i = 0; i <= n; i++) {
require(`${benchmarkDirectory}${i}/index.js`);
}
bench.end(n);
tmpdir.refresh();
}

function measureDir(n, useCache) {
function measureDir(n, cache, files, name) {
var i;
if (useCache) {
for (i = 0; i <= n; i++) {
require(`${benchmarkDirectory}${i}`);
if (cache) {
for (i = 0; i <= files; i++) {
require(`${benchmarkDirectory}${i}${name}`);
}
}
bench.start();
for (i = 0; i <= n; i++) {
require(`${benchmarkDirectory}${i}`);
for (i = 0; i <= files; i++) {
for (var j = 0; j < n; j++)
require(`${benchmarkDirectory}${i}${name}`);
// Pretend mixed input (otherwise the results are less representative due to
// highly specialized code).
require(otherModules[i % otherModules.length]);
}
bench.end(n);
bench.end(n * files);
}
Loading