Skip to content

Commit 7ab6586

Browse files
committed
fixup! fs: add c++ fast path for writeFileSync utf8
1 parent 12c0d7f commit 7ab6586

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

benchmark/fs/bench-writeFileSync.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ tmpdir.refresh();
88
const bench = common.createBenchmark(main, {
99
encoding: ['utf8'],
1010
hasFileDescriptor: ['true', 'false'],
11-
stringLength: [1024, 4096, 65535],
12-
// stringLength: [1024, 4096, 65535, 1024 * 1024],
11+
stringLength: [1024, 4096, 65535, 1024 * 1024],
12+
func: [ 'writeFile', 'appendFile' ],
1313
n: [1e3],
1414
});
1515

16-
function main({ n, encoding, stringLength, hasFileDescriptor }) {
16+
function main({ n, func, encoding, stringLength, hasFileDescriptor }) {
1717
tmpdir.refresh();
1818
const enc = encoding === 'undefined' ? undefined : encoding;
1919
const path = tmpdir.resolve(`.writefilesync-file-${Date.now()}`);
@@ -23,9 +23,11 @@ function main({ n, encoding, stringLength, hasFileDescriptor }) {
2323

2424
const data = 'a'.repeat(stringLength);
2525

26+
const fn = fs[func + 'Sync'];
27+
2628
bench.start();
2729
for (let i = 0; i < n; ++i) {
28-
fs.writeFileSync(file, data, enc);
30+
fn(file, data, enc);
2931
}
3032
bench.end(n);
3133

0 commit comments

Comments
 (0)