fs(readfile): merge `open` and `fstat`
Context
@anonrig shared this discussion with me . I spent time during the last weeks around the readFile
code.
Updates
Merge open
and fstat
into a single c++ function.
Gains
It's where I'm stuck, and it's probably linked to my implementation (
When I try to execute the targeted benchmark file: benchmark/fs/readfile.fs
- With my build
./node benchmark/fs/readfile.js
fs/readfile.js concurrent=1 len=16777216 encoding="" duration=5: 367.1841192868408
fs/readfile.js concurrent=1 len=16777216 encoding="utf-8" duration=5: 195.96019558527175
- With the main branch build
./node-main benchmark/fs/readfile.js
fs/readfile.js concurrent=1 len=1024 encoding="" duration=5: 34,928.87992225262
fs/readfile.js concurrent=10 len=1024 encoding="" duration=5: 98,718.82706159452
fs/readfile.js concurrent=1 len=16777216 encoding="" duration=5: 385.6378889225866
fs/readfile.js concurrent=10 len=16777216 encoding="" duration=5: 881.9940685898887
fs/readfile.js concurrent=1 len=1024 encoding="utf-8" duration=5: 35,145.19621474622
fs/readfile.js concurrent=10 len=1024 encoding="utf-8" duration=5: 99,417.17644259878
fs/readfile.js concurrent=1 len=16777216 encoding="utf-8" duration=5: 199.9139287372592
fs/readfile.js concurrent=10 len=16777216 encoding="utf-8" duration=5: 295.9984238083932
It looks like my implementation failed somewhere...
Note: it's my first c++ code