Skip to content

Commit bf217f8

Browse files
anonrigjuanarbol
authored andcommitted
fs: add encoding parameter to benchmarks
PR-URL: #44278 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]>
1 parent 0bf57df commit bf217f8

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

‎benchmark/fs/readfile-partitioned.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ const zlib = require('zlib');
1717
constassert=require('assert');
1818

1919
constbench=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-
functionmain({ len,dur, concurrent }){
26+
functionmain({ 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
functionread(){
53-
fs.readFile(filename,afterRead);
54+
fs.readFile(filename,encoding,afterRead);
5455
}
5556

5657
functionafterRead(er,data){

‎benchmark/fs/readfile-promises.js‎

Lines 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
constbench=common.createBenchmark(main,{
1717
duration: [5],
18+
encoding: ['','utf-8'],
1819
len: [1024,16*1024*1024],
1920
concurrent: [1,10]
2021
});
2122

22-
functionmain({ len, duration, concurrent }){
23+
functionmain({ 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
functionread(){
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‎

Lines 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
constbench=common.createBenchmark(main,{
1717
duration: [5],
18+
encoding: ['','utf-8'],
1819
len: [1024,16*1024*1024],
1920
concurrent: [1,10]
2021
});
2122

22-
functionmain({ len, duration, concurrent }){
23+
functionmain({ 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
functionread(){
47-
fs.readFile(filename,afterRead);
48+
fs.readFile(filename,encoding,afterRead);
4849
}
4950

5051
functionafterRead(er,data){

0 commit comments

Comments
(0)