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

v20.7.1 proposal #49917

Closed
wants to merge 145 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
8480280
bootstrap: only use the isolate snapshot when compiling code cache
joyeecheung Aug 18, 2023
31db0b8
build: add --write-snapshot-as-array-literals to configure.py
joyeecheung Aug 24, 2023
e7285d4
test_runner: fix typescript coverage
MoLow Sep 4, 2023
c3c6c4f
test: make test-worker-prof more robust
joyeecheung Sep 4, 2023
b9d4a80
doc: edit `import.meta.resolve` documentation
aduh95 Sep 5, 2023
2ceab87
deps: update corepack to 0.20.0
nodejs-github-bot Sep 5, 2023
f34bd15
esm: refactor mocking test
GeoffreyBooth Sep 5, 2023
a8a8a49
tools: update doc dependencies
nodejs-github-bot Sep 5, 2023
f755e67
test_runner: add jsdocs to MockTimers
ErickWendel Sep 5, 2023
2b11910
doc: updated releasers instructions for node.js website
ovflowd Sep 5, 2023
34c1741
test: add test for urlstrings usage in `node:fs`
LiviaMedeiros Sep 5, 2023
b4d42a8
test_runner: fix invalid timer call
ErickWendel Sep 5, 2023
ad043ba
process: add custom dir support for heapsnapshot-signal
MrJithil May 20, 2023
e426b77
doc: fix documentation for fs.createWriteStream highWaterMark option
mertcanaltin Sep 6, 2023
00608e8
lib: check SharedArrayBuffer availability in freeze_intrinsics.js
miniak Sep 6, 2023
f3fea92
doc: fix missing imports in `test.run` code examples
OshriAsulin Sep 6, 2023
9f8bea3
doc: fix documentation for input option in child_process
ariel-weiss Sep 6, 2023
17823b3
esm: refactor test-esm-named-exports
GeoffreyBooth Sep 4, 2023
e74a075
esm: refactor test-esm-loader-resolve-type
GeoffreyBooth Sep 4, 2023
fe26b74
meta: bump rtCamp/action-slack-notify from 2.2.0 to 2.2.1
dependabot[bot] Sep 7, 2023
5366027
meta: bump github/codeql-action from 2.21.2 to 2.21.5
dependabot[bot] Sep 7, 2023
e341efe
tools: configure never-stale label correctly
targos Sep 7, 2023
0471c57
doc: cast GetInternalField() return type to v8::Value in addons.md
joyeecheung Sep 7, 2023
15b54ff
deps: update googletest to 8a6feab
nodejs-github-bot Sep 7, 2023
3987094
test: make `test-dotenv-node-options` locale-independent
LiviaMedeiros Sep 7, 2023
39fb83a
src: do not rely on the internal field being default to undefined
joyeecheung Sep 7, 2023
cfbcb10
src: fix comment on StreamResource
ywave620 Aug 16, 2023
210c15b
tools: allow passing absolute path of config.gypi in js2c
zcbenz Sep 7, 2023
b4724e2
doc: close a parenthesis
regseb Sep 7, 2023
f214428
test: split test-crypto-dh to avoid timeout on slow machines in the CI
joyeecheung Sep 7, 2023
d0e0eb4
doc: update outdated history info
aduh95 Sep 7, 2023
2d3f5c7
src: fix fs_type_to_name default value
0o001 Sep 7, 2023
4b5e23c
src: set ModuleWrap internal fields only once
joyeecheung Sep 8, 2023
0f020ed
gyp: put cctest filenames in variables
zcbenz Sep 8, 2023
4126a6e
benchmark: fix webstream pipe-to
rluvaton Sep 8, 2023
8e033c3
doc: rename possibly confusing variable and CSS class
aduh95 Sep 8, 2023
e3594d5
doc: update documentation for node:process warning
shubham9411 Sep 8, 2023
be48267
esm: remove return value for `Module.register`
aduh95 Sep 9, 2023
ac06607
typings: fix missing property in `ExportedHooks`
aduh95 Sep 9, 2023
53fb5ae
doc: save user preference for JS flavor
eldoy Sep 9, 2023
be02fbd
test: isolate `globalPreload` tests
GeoffreyBooth Sep 9, 2023
ced25a9
test: increase coverage of `Module.register` and `initialize` hook
aduh95 Sep 10, 2023
c23c60f
zlib: disable CRC32 SIMD optimization
lpinca Sep 10, 2023
567afc7
test: avoid copying test source files
legendecas Sep 6, 2023
91af0a9
Revert "test: ignore the copied entry_point.c"
legendecas Sep 7, 2023
e515046
lib: use internal `pathToFileURL`
LiviaMedeiros Sep 10, 2023
f62d649
lib: use internal `fileURLToPath`
deokjinkim Sep 10, 2023
14ece0a
src: allow embedders to override NODE_MODULE_VERSION
zcbenz Sep 11, 2023
667a924
test: skip test-child-process-pipe-dataflow.js on Windows
joyeecheung Sep 11, 2023
fb21062
src: set --rehash-snapshot explicitly
joyeecheung Sep 11, 2023
c079c73
test: use setImmediate() in test-heapdump-shadowrealm.js
joyeecheung Sep 11, 2023
f79b153
test: use spawnSyncAndExitWithoutError in test/common/sea.js
joyeecheung Sep 7, 2023
3599eeb
test: use spawnSyncAndExitWithoutError in sea tests
joyeecheung Sep 7, 2023
ed7c6d1
test: mark test-http-regr-gh-2928 as flaky
joyeecheung Sep 11, 2023
db3fc6d
fs: fix readdir and opendir recursive with unknown file types
lux01 Sep 11, 2023
6377f1b
errors: use `determineSpecificType` in more error messages
aduh95 Sep 11, 2023
20d038f
tools: update lint-md-dependencies to rollup@3.29.0 unified@11.0.3
nodejs-github-bot Sep 12, 2023
728ebf6
tools: update eslint to 8.49.0
nodejs-github-bot Sep 12, 2023
c70c74a
test: show more info on failure in test-cli-syntax-require.js
joyeecheung Sep 12, 2023
1beefd5
esm: set all hooks as release candidate
GeoffreyBooth Sep 13, 2023
185d9b5
test: deflake test-tls-socket-close
lpinca Sep 13, 2023
6fcb51d
debugger: use `internal/url.URL` instead of `url.parse`
LiviaMedeiros Sep 11, 2023
08ffc63
tools: restrict internal code from using public `url` module
LiviaMedeiros Sep 11, 2023
78a6c73
benchmark: shorten pipe-to by reducing number of chunks
rluvaton Sep 13, 2023
5672e38
test_runner: add jsdocs to mock.js
ocodista Sep 14, 2023
17a05b1
test_runner: add junit reporter
MoLow Sep 14, 2023
7686551
test_runner: fix test runner watch mode when no positional arguments
MoLow Sep 14, 2023
ab3afb3
test: mark test-runner-watch-mode as flaky
joyeecheung Sep 14, 2023
3d839fb
doc: mark Node.js 16 as End-of-Life
richardlau Sep 14, 2023
c2eac7d
doc: remove `@anonrig` from performance initiative
anonrig Sep 13, 2023
6e56f2d
test: skip test-child-process-stdio-reuse-readable-stdio on Windows
joyeecheung Sep 14, 2023
3a9ea09
esm: clarify ERR_REQUIRE_ESM errors
danielcompton Sep 15, 2023
142e256
errors: improve classRegExp in errors.js
Uzlopak Sep 16, 2023
d316b32
doc: update `corepack.md` to account for 0.20.0 changes
aduh95 Sep 16, 2023
7b6a731
doc: deprecate calling `promisify` on a function that returns a promise
aduh95 Sep 16, 2023
521a932
esm: fix support for `URL` instances in `register`
aduh95 Sep 17, 2023
1424404
deps: update nghttp2 to 1.56.0
nodejs-github-bot Sep 17, 2023
938471e
fs: improve error performance of sync methods
anonrig Sep 17, 2023
9f0b0e1
doc: alphabetize cli.md sections
GeoffreyBooth Sep 17, 2023
6010a91
bootstrap: do not expand argv1 for snapshots
joyeecheung Sep 5, 2023
1fffda5
test: fix argument computation in embedtest
joyeecheung Sep 5, 2023
b30754a
build: run embedtest using node executable
joyeecheung Sep 5, 2023
a597cb8
src: port Pipe to uv_pipe_bind2, uv_pipe_connect2
ggoodman Sep 18, 2023
f611583
src: use SNAPSHOT_SERDES to log snapshot ser/deserialization
joyeecheung Sep 18, 2023
7c5e322
stream: improve webstream readable async iterator performance
rluvaton Sep 18, 2023
b9e5b43
test: deflake test-http-regr-gh-2928
lpinca Sep 9, 2023
ff81bfb
tools: update lint-md-dependencies to rollup@3.29.2
nodejs-github-bot Sep 19, 2023
a6140f1
esm: update loaders warning
GeoffreyBooth Sep 19, 2023
462228b
tools: fix uvwasi updater
mhdawson Sep 19, 2023
4879e3f
benchmark: add a benchmark for read() of ReadableStreams
debadree25 Sep 19, 2023
3529448
doc: fix print results in `events`
Sep 19, 2023
a304d1e
doc: link maintaining deps to pull-request.md
marco-ippolito Sep 19, 2023
b29d927
stream: improve readable webstream `pipeTo`
rluvaton Sep 19, 2023
e5185b0
test: use `fs.constants` for `fs.access` constants
LiviaMedeiros Sep 20, 2023
8a6f5fb
esm: fix return type of `import.meta.resolve`
aduh95 Sep 20, 2023
db4ab1c
doc: add missing history info for `import.meta.resolve`
aduh95 Sep 20, 2023
3a88571
doc: fix history comments
aduh95 Sep 20, 2023
2cc5ad7
Revert "test: mark test-http-regr-gh-2928 as flaky"
lpinca Sep 20, 2023
843df1a
test,crypto: update WebCryptoAPI WPT
panva Sep 21, 2023
4175ea3
doc: add missed `inspect` with numericSeparator to example
deokjinkim Sep 21, 2023
8a7c101
repl: don't accumulate excess indentation in .load
STRd6 Sep 21, 2023
fe78a34
doc: update output of example in `mimeParams.set()`
deokjinkim Sep 21, 2023
774c1cf
doc: add missing function call to example for `util.promisify`
Sep 21, 2023
bbc7105
lib: reset the cwd cache before execution
arcanis Sep 21, 2023
b618fe2
fs: improve error performance of `opendirSync`
anonrig Sep 21, 2023
58f7a9e
meta: add primordials strategic initiative
benjamingr Sep 21, 2023
a5dd057
doc: deprecate `util.toUSVString`
anonrig Sep 21, 2023
ce37688
src: remove unnecessary todo
RafaelGSS Sep 21, 2023
8bfbe70
meta: fix linter error
aduh95 Sep 21, 2023
1287d5b
lib: allow byob reader for 'blob.stream()'
debadree25 Sep 22, 2023
7c2060c
util: add `getCwdSafe` internal util fn
jlenon7 Sep 22, 2023
10a2ade
src: improve error message when ICU data cannot be initialized
joyeecheung Sep 15, 2023
e0f9349
doc: improve documentation about ICU data fallback
joyeecheung Sep 15, 2023
6c86c06
deps: update googletest to d1467f5
nodejs-github-bot Sep 22, 2023
05f0fcb
esm: identify parent importing a url with invalid host
JakobJingleheimer Sep 23, 2023
b8a4fef
deps: remove pthread-fixes.c from uv.gyp
bnoordhuis Sep 23, 2023
3db9b40
test: refactor test-readline-async-iterators into a benchmark
shubham9411 Sep 23, 2023
efd6815
lib: fix `internalBinding` typings
anonrig Sep 23, 2023
61d18d6
deps: update undici to 5.24.0
nodejs-github-bot Sep 23, 2023
0ce1e94
lib: update encoding sets in `WHATWG API`
Sep 23, 2023
5ac6722
tools: skip ruff on tools/node_modules
MoLow Sep 24, 2023
864fe56
doc: add `git node backport` way to the backporting guide
rluvaton Sep 24, 2023
0ccd463
stream: use bitmap in readable state
benjamingr Sep 24, 2023
80b342c
test_runner: accept `testOnly` in `run`
MoLow Sep 24, 2023
835f9fe
fs: fix file descriptor validator
anonrig Sep 24, 2023
0fbbe49
doc: promote fetch/webstreams from experimental to stable
styfle Sep 24, 2023
6a88c6a
doc: add mertcanaltin as a triager
Sep 23, 2023
9600928
node-api: enable uncaught exceptions policy by default
legendecas Sep 25, 2023
ddf0e17
doc,tools: switch to `@node-core/utils`
targos Sep 25, 2023
eded29c
test: use mustSucceed instead of mustCall
SiddharthDevulapalli Sep 25, 2023
1f16df2
deps: V8: cherry-pick b33bf2dfd261
joyeecheung Jul 20, 2023
aea7371
deps: V8: backport de9a5de2274f
joyeecheung Sep 18, 2023
f4041ce
doc: deprecate `fs.F_OK`, `fs.R_OK`, `fs.W_OK`, `fs.X_OK`
LiviaMedeiros Sep 25, 2023
690cca3
doc: fix `DEP0176` number
LiviaMedeiros Sep 25, 2023
d2bcdcb
test: mark test-runner-output as flaky
joyeecheung Sep 25, 2023
07d0518
fs: improve `readFileSync` with file descriptors
anonrig Sep 25, 2023
6db0d3d
tools: support updating @reporters/github manually
MoLow Sep 26, 2023
7d91a73
url: improve invalid url performance
anonrig Sep 26, 2023
12fe6a0
stream: use bitmap in writable state
rluvaton Sep 26, 2023
d44a812
test: deflake test-runner-output
MoLow Sep 26, 2023
f40b5ed
perf_hooks: reduce overhead of new performance_entries
H4ad Sep 27, 2023
e82e46c
fs: improve error performance for `unlinkSync`
CanadaHonk Sep 27, 2023
9363179
fs: replace `SetMethodNoSideEffect` in node_file
CanadaHonk Sep 27, 2023
1a18034
test: add os setPriority, getPriority test coverage
waelsy123 Sep 27, 2023
eee298e
2023-09-28, Version 20.7.1 (Current)
ruyadorno Sep 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .github/workflows/auto-start-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ jobs:
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install node-core-utils
run: npm install -g node-core-utils
- name: Install @node-core/utils
run: npm install -g @node-core/utils

- name: Setup node-core-utils
- name: Setup @node-core/utils
run: |
ncu-config set username ${{ secrets.JENKINS_USER }}
ncu-config set token "${{ secrets.GH_USER_TOKEN }}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/close-stale-feature-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
close-issue-message: ${{ env.CLOSE_MESSAGE }}
stale-issue-message: ${{ env.WARN_MESSAGE }}
only-labels: feature request
exempt-pr-labels: never-stale
exempt-issue-labels: never-stale
# max requests it will send per run to the GitHub API before it deliberately exits to avoid hitting API rate limits
operations-per-run: 500
remove-stale-when-updated: true
6 changes: 3 additions & 3 deletions .github/workflows/commit-queue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ jobs:
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install node-core-utils
run: npm install -g node-core-utils@latest
- name: Install @node-core/utils
run: npm install -g @node-core/utils

- name: Set variables
run: |
echo "REPOSITORY=$(echo ${{ github.repository }} | cut -d/ -f2)" >> $GITHUB_ENV
echo "OWNER=${{ github.repository_owner }}" >> $GITHUB_ENV

- name: Configure node-core-utils
- name: Configure @node-core/utils
run: |
ncu-config set branch ${GITHUB_REF_NAME}
ncu-config set upstream origin
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/notify-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Slack Notification
uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7
uses: rtCamp/action-slack-notify@b24d75fe0e728a4bf9fc42ee217caa686d141ee8 # 2.2.1
env:
SLACK_COLOR: '#DE512A'
SLACK_ICON: https://github.com/nodejs.png?size=48
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
GH_TOKEN: ${{ github.token }}
- name: Slack Notification
if: ${{ env.INVALID_COMMIT_MESSAGE }}
uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7
uses: rtCamp/action-slack-notify@b24d75fe0e728a4bf9fc42ee217caa686d141ee8 # 2.2.1
env:
SLACK_COLOR: '#DE512A'
SLACK_ICON: https://github.com/nodejs.png?size=48
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: Upload to code-scanning
uses: github/codeql-action/upload-sarif@0ba4244466797eb048eb91a6cd43d5c03ca8bd05 # v2.21.2
uses: github/codeql-action/upload-sarif@00e563ead9f72a8461b24876bee2d0c2e8bd2ee8 # v2.21.5
with:
sarif_file: results.sarif
1 change: 1 addition & 0 deletions .github/workflows/tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ on:
- corepack
- doc
- eslint
- github_reporter
- googletest
- histogram
- icu
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update-v8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install node-core-utils
run: npm install -g node-core-utils@latest
- name: Install @node-core/utils
run: npm install -g @node-core/utils
- name: Check and download new V8 version
run: |
./tools/dep_updaters/update-v8-patch.sh > temp-output
Expand Down
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Ref: https://github.com/gitpod-io/gitpod/issues/6283#issuecomment-1001043454
tasks:
- init: ./configure && timeout 50m make -j16 || true
- init: pnpm i -g node-core-utils
- init: pnpm i -g @node-core/utils

# Ref: https://www.gitpod.io/docs/prebuilds#github-specific-configuration
github:
Expand Down
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Select a Node.js version below to view the changelog history:
* [Node.js 19](doc/changelogs/CHANGELOG_V19.md) **Current**
* [Node.js 18](doc/changelogs/CHANGELOG_V18.md) **Long Term Support**
* [Node.js 17](doc/changelogs/CHANGELOG_V17.md) End-of-Life
* [Node.js 16](doc/changelogs/CHANGELOG_V16.md) **Long Term Support**
* [Node.js 16](doc/changelogs/CHANGELOG_V16.md) End-of-Life
* [Node.js 15](doc/changelogs/CHANGELOG_V15.md) End-of-Life
* [Node.js 14](doc/changelogs/CHANGELOG_V14.md) End-of-Life
* [Node.js 13](doc/changelogs/CHANGELOG_V13.md) End-of-Life
Expand Down Expand Up @@ -36,7 +36,8 @@ release.
</tr>
<tr>
<td valign="top">
<b><a href="doc/changelogs/CHANGELOG_V20.md#20.7.0">20.7.0</a></b><br/>
<b><a href="doc/changelogs/CHANGELOG_V20.md#20.7.1">20.7.1</a></b><br/>
<a href="doc/changelogs/CHANGELOG_V20.md#20.7.0">20.7.0</a><br/>
<a href="doc/changelogs/CHANGELOG_V20.md#20.6.1">20.6.1</a><br/>
<a href="doc/changelogs/CHANGELOG_V20.md#20.6.0">20.6.0</a><br/>
<a href="doc/changelogs/CHANGELOG_V20.md#20.5.1">20.5.1</a><br/>
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ coverage-report-js:
# Runs the C++ tests using the built `cctest` executable.
cctest: all
@out/$(BUILDTYPE)/$@ --gtest_filter=$(GTEST_FILTER)
@out/$(BUILDTYPE)/embedtest "require('./test/embedding/test-embedding.js')"
$(NODE) ./test/embedding/test-embedding.js

.PHONY: list-gtests
list-gtests:
Expand Down Expand Up @@ -550,7 +550,7 @@ test-ci: | clear-stalled bench-addons-build build-addons build-js-native-api-tes
$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
--mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \
$(TEST_CI_ARGS) $(CI_JS_SUITES) $(CI_NATIVE_SUITES) $(CI_DOC)
out/Release/embedtest 'require("./test/embedding/test-embedding.js")'
$(NODE) ./test/embedding/test-embedding.js
$(info Clean up any leftover processes, error if found.)
ps awwx | grep Release/node | grep -v grep | cat
@PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \
Expand Down Expand Up @@ -1423,6 +1423,7 @@ FORMAT_CPP_FILES += $(LINT_CPP_FILES)
# C source codes.
FORMAT_CPP_FILES += $(wildcard \
benchmark/napi/*/*.c \
test/js-native-api/*.h \
test/js-native-api/*/*.c \
test/js-native-api/*/*.h \
test/node-api/*/*.c \
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,8 @@ maintaining the Node.js project.
**Akhil Marsonya** <<akhil.marsonya27@gmail.com>> (he/him)
* [meixg](https://github.com/meixg) -
**Xuguang Mei** <<meixuguang@gmail.com>> (he/him)
* [mertcanaltin](https://github.com/mertcanaltin) -
**Mert Can Altin** <<mertgold60@gmail.com>>
* [Mesteery](https://github.com/Mesteery) -
**Mestery** <<mestery@protonmail.com>> (he/him)
* [preveen-stack](https://github.com/preveen-stack) -
Expand Down
23 changes: 23 additions & 0 deletions benchmark/error/error-class-reg-exp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

const common = require('../common.js');

const bench = common.createBenchmark(main, {
n: [1e5],
}, {
flags: ['--expose-internals'],
});

const instances = Array.from({ length: 1000 }).map(() => 'Uint8Array');

function main({ n }) {
const {
codes: {
ERR_INVALID_ARG_TYPE,
},
} = require('internal/errors');
bench.start();
for (let i = 0; i < n; ++i)
new ERR_INVALID_ARG_TYPE('target', instances, 'test');
bench.end(n);
}
42 changes: 42 additions & 0 deletions benchmark/fs/bench-accessSync.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';

const common = require('../common');
const fs = require('fs');
const tmpdir = require('../../test/common/tmpdir');
tmpdir.refresh();

const tmpfile = tmpdir.resolve(`.existing-file-${process.pid}`);
fs.writeFileSync(tmpfile, 'this-is-for-a-benchmark', 'utf8');

const bench = common.createBenchmark(main, {
type: ['existing', 'non-existing', 'non-flat-existing'],
n: [1e5],
});

function main({ n, type }) {
let path;

switch (type) {
case 'existing':
path = __filename;
break;
case 'non-flat-existing':
path = tmpfile;
break;
case 'non-existing':
path = tmpdir.resolve(`.non-existing-file-${process.pid}`);
break;
default:
new Error('Invalid type');
}

bench.start();
for (let i = 0; i < n; i++) {
try {
fs.accessSync(path);
} catch {
// do nothing
}
}
bench.end(n);
}
37 changes: 37 additions & 0 deletions benchmark/fs/bench-copyFileSync.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'use strict';

const common = require('../common');
const fs = require('fs');
const tmpdir = require('../../test/common/tmpdir');
tmpdir.refresh();

const bench = common.createBenchmark(main, {
type: ['invalid', 'valid'],
n: [1e4],
});

function main({ n, type }) {
tmpdir.refresh();
const dest = tmpdir.resolve(`copy-file-bench-${process.pid}`);
let path;

switch (type) {
case 'invalid':
path = tmpdir.resolve(`.existing-file-${process.pid}`);
break;
case 'valid':
path = __filename;
break;
default:
throw new Error('Invalid type');
}
bench.start();
for (let i = 0; i < n; i++) {
try {
fs.copyFileSync(path, dest);
} catch {
// do nothing
}
}
bench.end(n);
}
38 changes: 38 additions & 0 deletions benchmark/fs/bench-existsSync.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict';

const common = require('../common');
const fs = require('fs');
const tmpdir = require('../../test/common/tmpdir');
tmpdir.refresh();

const tmpfile = tmpdir.resolve(`.existing-file-${process.pid}`);
fs.writeFileSync(tmpfile, 'this-is-for-a-benchmark', 'utf8');

const bench = common.createBenchmark(main, {
type: ['existing', 'non-existing', 'non-flat-existing'],
n: [1e6],
});

function main({ n, type }) {
let path;

switch (type) {
case 'existing':
path = __filename;
break;
case 'non-flat-existing':
path = tmpfile;
break;
case 'non-existing':
path = tmpdir.resolve(`.non-existing-file-${process.pid}`);
break;
default:
new Error('Invalid type');
}

bench.start();
for (let i = 0; i < n; i++) {
fs.existsSync(path);
}
bench.end(n);
}
37 changes: 37 additions & 0 deletions benchmark/fs/bench-openSync.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'use strict';

const common = require('../common');
const fs = require('fs');
const tmpdir = require('../../test/common/tmpdir');
tmpdir.refresh();

const bench = common.createBenchmark(main, {
type: ['existing', 'non-existing'],
n: [1e5],
});

function main({ n, type }) {
let path;

switch (type) {
case 'existing':
path = __filename;
break;
case 'non-existing':
path = tmpdir.resolve(`.non-existing-file-${process.pid}`);
break;
default:
new Error('Invalid type');
}

bench.start();
for (let i = 0; i < n; i++) {
try {
const fd = fs.openSync(path, 'r', 0o666);
fs.closeSync(fd);
} catch {
// do nothing
}
}
bench.end(n);
}
43 changes: 43 additions & 0 deletions benchmark/fs/bench-opendirSync.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict';

const common = require('../common');
const fs = require('fs');
const path = require('path');
const tmpdir = require('../../test/common/tmpdir');
tmpdir.refresh();

const testFiles = fs.readdirSync('test', { withFileTypes: true })
.filter((f) => f.isDirectory())
.map((f) => path.join(f.path, f.name));
const bench = common.createBenchmark(main, {
type: ['existing', 'non-existing'],
n: [1e3],
});

function main({ n, type }) {
let files;

switch (type) {
case 'existing':
files = testFiles;
break;
case 'non-existing':
files = [tmpdir.resolve(`.non-existing-file-${Date.now()}`)];
break;
default:
new Error('Invalid type');
}

bench.start();
for (let i = 0; i < n; i++) {
for (let j = 0; j < files.length; j++) {
try {
const dir = fs.opendirSync(files[j]);
dir.closeSync();
} catch {
// do nothing
}
}
}
bench.end(n);
}
Loading