I got to thinking:
" Why have the
file_read
andfile_write
components never gotten C++ implementations? "
So, I set about trying to make some, largely as an excuse to teach myself how to do raw file IO in C++.
My implementations can be found here:
I have not exhaustively tested these, but:
- All the main framework tests run with my
file_read_cc
instead of the normalfile_read
. - The naive benchmark included in
demo.sh
suggests that on my home PC whilst I had other stuff running / open, the combination of the new implementations is:- ~100% (2x) faster for:
messagesize
= up to 64,messagesinfile
= false,repeat
= false
- ~60 to 80% faster for:
messagesize
= 128 to 2048,messagesinfile
= false,repeat
= false- Speed decreases as
messagesize
increases
- ~30% faster for:
messagesize
= 4096 and 8192,messagesinfile
= false,repeat
= false
- ~100% (2x) faster for:
messagesize
up to 512,messagesinfile
= false,repeat
= true
- ~60% faster for:
messagesize
= 1024,messagesinfile
= false,repeat
= true
- ~20% faster for:
messagesize
= 2048,messagesinfile
= false,repeat
= true
- ~10% slower for:
messagesize
= 4096 and 8192,messagesinfile
= false,repeat
= true
- ~100% (2x) faster for:
Note: I have only tested file_write
with testbias
, and the error messages are not particularly descriptive.
Feel free to try these (noting the MIT license) and I do not make any guarantees that they work with all inputs.