fs: move getValidMode to c++ for better performance
confidence improvement accuracy (*) (**) (***)
fs/bench-copyFileSync.js n=10000 type='invalid mode' *** 69.61 % ±10.49% ±14.01% ±18.33%
fs/bench-copyFileSync.js n=10000 type='invalid path' 1.58 % ±6.12% ±8.14% ±10.59%
fs/bench-copyFileSync.js n=10000 type='valid' 1.90 % ±10.90% ±14.50% ±18.88%
Be aware that when doing many comparisons the risk of a false-positive result increases.
In this case, there are 3 comparisons, you can thus expect the following amount of false-positive results:
0.15 false positives, when considering a 5% risk acceptance (*, **, ***),
0.03 false positives, when considering a 1% risk acceptance (**, ***),
0.00 false positives, when considering a 0.1% risk acceptance (***)
confidence improvement accuracy (*) (**) (***)
fs/bench-accessSync.js n=100000 type='existing' -2.88 % ±6.17% ±8.22% ±10.72%
fs/bench-accessSync.js n=100000 type='invalid-mode' *** 52.14 % ±10.53% ±14.03% ±18.30%
fs/bench-accessSync.js n=100000 type='non-existing' -0.87 % ±5.86% ±7.80% ±10.17%
fs/bench-accessSync.js n=100000 type='non-flat-existing' 0.83 % ±6.60% ±8.78% ±11.43%
Be aware that when doing many comparisons the risk of a false-positive result increases.
In this case, there are 4 comparisons, you can thus expect the following amount of false-positive results:
0.20 false positives, when considering a 5% risk acceptance (*, **, ***),
0.04 false positives, when considering a 1% risk acceptance (**, ***),
0.00 false positives, when considering a 0.1% risk acceptance (***)
Ref: https://github.com/nodejs/performance/issues/111
The improvements are noticeable for cases where an error related to mode
is thrown.
Thanks to @anonrig for the idea.