Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4ec3f67

Browse filesBrowse files
anonrigruyadorno
authored andcommitted
fs: add encoding parameter to benchmarks
PR-URL: #44278 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
1 parent f7c1b83 commit 4ec3f67
Copy full SHA for 4ec3f67

File tree

Expand file treeCollapse file tree

3 files changed

+11
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+11
-8
lines changed
Open diff view settings
Collapse file

‎benchmark/fs/readfile-partitioned.js‎

Copy file name to clipboardExpand all lines: benchmark/fs/readfile-partitioned.js
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ const zlib = require('zlib');
1717
const assert = require('assert');
1818

1919
const bench = common.createBenchmark(main, {
20-
dur: [5],
20+
duration: [5],
21+
encoding: ['', 'utf-8'],
2122
len: [1024, 16 * 1024 * 1024],
2223
concurrent: [1, 10]
2324
});
2425

25-
function main({ len, dur, concurrent }) {
26+
function main({ len, duration, concurrent, encoding }) {
2627
try {
2728
fs.unlinkSync(filename);
2829
} catch {
@@ -47,10 +48,10 @@ function main({ len, dur, concurrent }) {
4748
} catch {
4849
// Continue regardless of error.
4950
}
50-
}, dur * 1000);
51+
}, duration * 1000);
5152

5253
function read() {
53-
fs.readFile(filename, afterRead);
54+
fs.readFile(filename, encoding, afterRead);
5455
}
5556

5657
function afterRead(er, data) {
Collapse file

‎benchmark/fs/readfile-promises.js‎

Copy file name to clipboardExpand all lines: benchmark/fs/readfile-promises.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ const filename = path.resolve(tmpdir.path,
1515

1616
const bench = common.createBenchmark(main, {
1717
duration: [5],
18+
encoding: ['', 'utf-8'],
1819
len: [1024, 16 * 1024 * 1024],
1920
concurrent: [1, 10]
2021
});
2122

22-
function main({ len, duration, concurrent }) {
23+
function main({ len, duration, concurrent, encoding }) {
2324
try {
2425
fs.unlinkSync(filename);
2526
} catch {
@@ -44,7 +45,7 @@ function main({ len, duration, concurrent }) {
4445
}, duration * 1000);
4546

4647
function read() {
47-
fs.promises.readFile(filename)
48+
fs.promises.readFile(filename, encoding)
4849
.then((res) => afterRead(undefined, res))
4950
.catch((err) => afterRead(err));
5051
}
Collapse file

‎benchmark/fs/readfile.js‎

Copy file name to clipboardExpand all lines: benchmark/fs/readfile.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ const filename = path.resolve(tmpdir.path,
1515

1616
const bench = common.createBenchmark(main, {
1717
duration: [5],
18+
encoding: ['', 'utf-8'],
1819
len: [1024, 16 * 1024 * 1024],
1920
concurrent: [1, 10]
2021
});
2122

22-
function main({ len, duration, concurrent }) {
23+
function main({ len, duration, concurrent, encoding }) {
2324
try {
2425
fs.unlinkSync(filename);
2526
} catch {
@@ -44,7 +45,7 @@ function main({ len, duration, concurrent }) {
4445
}, duration * 1000);
4546

4647
function read() {
47-
fs.readFile(filename, afterRead);
48+
fs.readFile(filename, encoding, afterRead);
4849
}
4950

5051
function afterRead(er, data) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.