Skip to content

Commit 4ec3f67

Browse 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

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

benchmark/fs/readfile-partitioned.js

+5-4
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) {

benchmark/fs/readfile-promises.js

+3-2
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
}

benchmark/fs/readfile.js

+3-2
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)