mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
fs: add encoding parameter to benchmarks
PR-URL: https://github.com/nodejs/node/pull/44278 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
This commit is contained in:
1 parent
f7c1b838ba
commit
4ec3f671af
3 files changed
+11
-8
No files matched your search
@@ -17,12 +17,13 @@ const zlib = require('zlib');
|
||||
const assert = require('assert');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
dur: [5],
|
||||
duration: [5],
|
||||
encoding: ['', 'utf-8'],
|
||||
len: [1024, 16 * 1024 * 1024],
|
||||
concurrent: [1, 10]
|
||||
});
|
||||
|
||||
function main({ len, dur, concurrent }) {
|
||||
function main({ len, duration, concurrent, encoding }) {
|
||||
try {
|
||||
fs.unlinkSync(filename);
|
||||
} catch {
|
||||
@@ -47,10 +48,10 @@ function main({ len, dur, concurrent }) {
|
||||
} catch {
|
||||
// Continue regardless of error.
|
||||
}
|
||||
}, dur * 1000);
|
||||
}, duration * 1000);
|
||||
|
||||
function read() {
|
||||
fs.readFile(filename, afterRead);
|
||||
fs.readFile(filename, encoding, afterRead);
|
||||
}
|
||||
|
||||
function afterRead(er, data) {
|
||||
|
||||
@@ -15,11 +15,12 @@ const filename = path.resolve(tmpdir.path,
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
duration: [5],
|
||||
encoding: ['', 'utf-8'],
|
||||
len: [1024, 16 * 1024 * 1024],
|
||||
concurrent: [1, 10]
|
||||
});
|
||||
|
||||
function main({ len, duration, concurrent }) {
|
||||
function main({ len, duration, concurrent, encoding }) {
|
||||
try {
|
||||
fs.unlinkSync(filename);
|
||||
} catch {
|
||||
@@ -44,7 +45,7 @@ function main({ len, duration, concurrent }) {
|
||||
}, duration * 1000);
|
||||
|
||||
function read() {
|
||||
fs.promises.readFile(filename)
|
||||
fs.promises.readFile(filename, encoding)
|
||||
.then((res) => afterRead(undefined, res))
|
||||
.catch((err) => afterRead(err));
|
||||
}
|
||||
|
||||
@@ -15,11 +15,12 @@ const filename = path.resolve(tmpdir.path,
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
duration: [5],
|
||||
encoding: ['', 'utf-8'],
|
||||
len: [1024, 16 * 1024 * 1024],
|
||||
concurrent: [1, 10]
|
||||
});
|
||||
|
||||
function main({ len, duration, concurrent }) {
|
||||
function main({ len, duration, concurrent, encoding }) {
|
||||
try {
|
||||
fs.unlinkSync(filename);
|
||||
} catch {
|
||||
@@ -44,7 +45,7 @@ function main({ len, duration, concurrent }) {
|
||||
}, duration * 1000);
|
||||
|
||||
function read() {
|
||||
fs.readFile(filename, afterRead);
|
||||
fs.readFile(filename, encoding, afterRead);
|
||||
}
|
||||
|
||||
function afterRead(er, data) {
|
||||
|
||||
Reference in new issue
Block a user