path: support file urls
This PR changes the path functions to support File URLs.
Related to #41521 Related to #49273 Successor of #52497
Review requested:
- [ ] @nodejs/url
Failed to start CI
⚠ No approving reviews found ✘ Refusing to run CI on potentially unsafe PRhttps://github.com/nodejs/node/actions/runs/8823064389
That's a good sign (for security) [i think]
Do CIs now need approving reviews? 🎉
They don't strictly need it. Collaborators can still start CI jobs from Jenkins.
Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1534/
Results
00:16:45 confidence improvement accuracy (*) (**) (***)
00:16:45 path/basename-posix.js n=100000 pathext='' *** -19.60 % ±0.67% ±0.89% ±1.14%
00:16:45 path/basename-posix.js n=100000 pathext='/' *** -18.94 % ±0.76% ±1.00% ±1.28%
00:16:45 path/basename-posix.js n=100000 pathext='/foo' *** -14.02 % ±1.07% ±1.42% ±1.83%
00:16:45 path/basename-posix.js n=100000 pathext='/foo/.bar.baz' *** -5.28 % ±1.29% ±1.70% ±2.18%
00:16:45 path/basename-posix.js n=100000 pathext='/foo/.bar.baz|.baz' *** -11.79 % ±1.59% ±2.10% ±2.70%
00:16:45 path/basename-posix.js n=100000 pathext='/foo/bar/baz/asdf/quux.html' *** -7.71 % ±1.31% ±1.73% ±2.23%
00:16:45 path/basename-posix.js n=100000 pathext='/foo/bar/baz/asdf/quux.html|.html' *** -11.62 % ±1.37% ±1.81% ±2.33%
00:16:45 path/basename-posix.js n=100000 pathext='foo' *** -19.75 % ±0.65% ±0.86% ±1.10%
00:16:45 path/basename-posix.js n=100000 pathext='foo/bar.' *** -13.49 % ±0.85% ±1.12% ±1.44%
00:16:45 path/basename-posix.js n=100000 pathext='foo/bar.|.' *** -8.65 % ±1.16% ±1.54% ±1.97%
00:16:45 path/basename-win32.js n=100000 pathext='' *** -18.07 % ±0.91% ±1.20% ±1.54%
00:16:45 path/basename-win32.js n=100000 pathext='\\\\foo\\\\bar\\\\baz\\\\asdf\\\\quux.html' *** -13.61 % ±1.06% ±1.40% ±1.79%
00:16:45 path/basename-win32.js n=100000 pathext='\\\\foo\\\\bar\\\\baz\\\\asdf\\\\quux.html|.html' -0.32 % ±1.15% ±1.52% ±1.96%
00:16:45 path/basename-win32.js n=100000 pathext='C:\\\\' *** -17.50 % ±1.13% ±1.49% ±1.91%
00:16:45 path/basename-win32.js n=100000 pathext='C:\\\\foo' *** -10.95 % ±0.85% ±1.12% ±1.44%
00:16:45 path/basename-win32.js n=100000 pathext='D:\\\\foo\\\\.bar.baz' *** -15.08 % ±0.85% ±1.13% ±1.45%
00:16:45 path/basename-win32.js n=100000 pathext='E:\\\\foo\\\\.bar.baz|.baz' *** -8.39 % ±0.84% ±1.11% ±1.43%
00:16:45 path/basename-win32.js n=100000 pathext='foo' *** -17.80 % ±0.57% ±0.75% ±0.97%
00:16:45 path/basename-win32.js n=100000 pathext='foo\\\\bar.' *** -13.31 % ±0.79% ±1.04% ±1.34%
00:16:45 path/basename-win32.js n=100000 pathext='foo\\\\bar.|.' *** -6.67 % ±0.97% ±1.28% ±1.65%
00:16:45 path/dirname-posix.js n=100000 path='' *** -21.31 % ±1.19% ±1.58% ±2.03%
00:16:45 path/dirname-posix.js n=100000 path='/' *** -18.26 % ±0.71% ±0.94% ±1.21%
00:16:45 path/dirname-posix.js n=100000 path='/foo' *** -16.69 % ±0.51% ±0.68% ±0.87%
00:16:45 path/dirname-posix.js n=100000 path='/foo/bar' *** -13.29 % ±0.61% ±0.80% ±1.03%
00:16:45 path/dirname-posix.js n=100000 path='/foo/bar/baz/asdf/quux' *** -11.64 % ±0.98% ±1.30% ±1.67%
00:16:45 path/dirname-posix.js n=100000 path='foo' *** -12.39 % ±0.76% ±1.00% ±1.28%
00:16:45 path/dirname-posix.js n=100000 path='foo/bar' *** -18.93 % ±0.38% ±0.51% ±0.65%
00:16:45 path/dirname-win32.js n=100000 path='' *** -15.76 % ±0.98% ±1.29% ±1.65%
00:16:45 path/dirname-win32.js n=100000 path='\\\\' *** -14.66 % ±0.96% ±1.27% ±1.63%
00:16:45 path/dirname-win32.js n=100000 path='\\\\foo' *** -16.40 % ±0.67% ±0.89% ±1.14%
00:16:45 path/dirname-win32.js n=100000 path='C:\\\\foo\\\\bar' *** -11.84 % ±0.85% ±1.12% ±1.43%
00:16:45 path/dirname-win32.js n=100000 path='D:\\\\foo\\\\bar\\\\baz\\\\asdf\\\\quux' *** -7.00 % ±1.08% ±1.43% ±1.85%
00:16:45 path/dirname-win32.js n=100000 path='foo' *** -14.32 % ±0.93% ±1.23% ±1.59%
00:16:45 path/dirname-win32.js n=100000 path='foo\\\\bar' *** -13.92 % ±0.39% ±0.52% ±0.66%
00:16:45 path/extname-posix.js n=100000 path='' *** -26.90 % ±1.79% ±2.36% ±3.05%
00:16:45 path/extname-posix.js n=100000 path='/' *** -24.56 % ±1.12% ±1.48% ±1.90%
00:16:45 path/extname-posix.js n=100000 path='/foo' *** -13.80 % ±0.90% ±1.19% ±1.53%
00:16:45 path/extname-posix.js n=100000 path='/foo/bar/baz/asdf/quux.foobarbazasdfquux' *** -9.01 % ±1.24% ±1.63% ±2.10%
00:16:45 path/extname-posix.js n=100000 path='/foo/bar/baz/asdf/quux' *** -6.55 % ±0.97% ±1.28% ±1.64%
00:16:45 path/extname-posix.js n=100000 path='foo/.bar.baz' *** -6.49 % ±1.16% ±1.53% ±1.97%
00:16:45 path/extname-posix.js n=100000 path='foo/bar/...baz.quux' *** -4.33 % ±1.57% ±2.07% ±2.66%
00:16:45 path/extname-posix.js n=100000 path='foo/bar/..baz.quux' *** -4.49 % ±0.90% ±1.19% ±1.53%
00:16:45 path/extname-posix.js n=100000 path='index.html' *** -6.88 % ±1.44% ±1.90% ±2.45%
00:16:45 path/extname-posix.js n=100000 path='index' *** -16.85 % ±0.70% ±0.93% ±1.19%
00:16:45 path/extname-win32.js n=100000 path='' *** -20.19 % ±1.03% ±1.36% ±1.75%
00:16:45 path/extname-win32.js n=100000 path='\\\\' *** -19.16 % ±1.13% ±1.49% ±1.92%
00:16:45 path/extname-win32.js n=100000 path='\\\\foo\\\\bar\\\\baz\\\\asdf\\\\quux.foobarbazasdfquux' *** -6.78 % ±1.58% ±2.08% ±2.68%
00:16:45 path/extname-win32.js n=100000 path='C:\\\\foo' *** -12.76 % ±0.91% ±1.20% ±1.55%
00:16:45 path/extname-win32.js n=100000 path='D:\\\\foo\\\\bar\\\\baz\\\\asdf\\\\quux' *** -9.55 % ±1.16% ±1.54% ±1.98%
00:16:45 path/extname-win32.js n=100000 path='foo\\\\.bar.baz' *** -8.78 % ±0.82% ±1.08% ±1.38%
00:16:45 path/extname-win32.js n=100000 path='foo\\\\bar\\\\...baz.quux' *** -6.27 % ±0.77% ±1.02% ±1.32%
00:16:45 path/extname-win32.js n=100000 path='foo\\\\bar\\\\..baz.quux' *** -6.64 % ±1.05% ±1.39% ±1.79%
00:16:45 path/extname-win32.js n=100000 path='index.html' *** -9.13 % ±1.00% ±1.32% ±1.70%
00:16:45 path/extname-win32.js n=100000 path='index' *** -11.56 % ±0.97% ±1.28% ±1.65%
00:16:45 path/format-posix.js n=1000000 props='/|/home/user/dir|index.html|.html|index' 0.24 % ±0.41% ±0.54% ±0.70%
00:16:45 path/format-win32.js n=1000000 props='C:\\\\|C:\\\\path\\\\dir|index.html|.html|index' -0.17 % ±0.44% ±0.58% ±0.74%
00:16:45 path/isAbsolute-posix.js n=100000 path='.' *** -23.85 % ±0.61% ±0.81% ±1.04%
00:16:45 path/isAbsolute-posix.js n=100000 path='' *** -28.10 % ±1.22% ±1.62% ±2.08%
00:16:45 path/isAbsolute-posix.js n=100000 path='/baz/..' *** -23.75 % ±0.43% ±0.57% ±0.73%
00:16:45 path/isAbsolute-posix.js n=100000 path='/foo/bar' *** -24.11 % ±0.63% ±0.84% ±1.07%
00:16:45 path/isAbsolute-posix.js n=100000 path='bar/baz' *** -23.61 % ±0.52% ±0.69% ±0.88%
00:16:45 path/isAbsolute-win32.js n=100000 path='.' *** -21.81 % ±0.67% ±0.88% ±1.14%
00:16:45 path/isAbsolute-win32.js n=100000 path='' *** -22.27 % ±0.89% ±1.17% ±1.51%
00:16:45 path/isAbsolute-win32.js n=100000 path='//server' *** -22.59 % ±0.95% ±1.25% ±1.61%
00:16:45 path/isAbsolute-win32.js n=100000 path='bar\\\\baz' *** -22.66 % ±0.47% ±0.62% ±0.79%
00:16:45 path/isAbsolute-win32.js n=100000 path='C:\\\\baz\\\\..' *** -15.54 % ±0.53% ±0.71% ±0.91%
00:16:45 path/isAbsolute-win32.js n=100000 path='C:baz\\\\..' *** -15.36 % ±0.58% ±0.77% ±0.99%
00:16:45 path/join-posix.js n=100000 paths='/foo|bar||baz/asdf|quux|..' *** -11.15 % ±0.48% ±0.64% ±0.82%
00:16:45 path/join-win32.js n=100000 paths='C:\\\\foo|bar||baz\\\\asdf|quux|..' *** -8.50 % ±0.44% ±0.58% ±0.74%
00:16:45 path/makeLong-win32.js n=100000 path='\\\\\\\\?\\\\foo' *** -8.99 % ±0.74% ±0.97% ±1.25%
00:16:45 path/makeLong-win32.js n=100000 path='\\\\\\\\foo\\\\bar' *** -9.08 % ±0.66% ±0.87% ±1.12%
00:16:45 path/makeLong-win32.js n=100000 path='C:\\\\foo' *** -8.34 % ±1.02% ±1.35% ±1.74%
00:16:45 path/makeLong-win32.js n=100000 path='foo\\\\bar' *** -4.10 % ±0.33% ±0.44% ±0.56%
00:16:45 path/normalize-posix.js n=100000 path='.' *** -12.86 % ±0.88% ±1.16% ±1.49%
00:16:45 path/normalize-posix.js n=100000 path='' *** -17.22 % ±1.32% ±1.75% ±2.25%
00:16:45 path/normalize-posix.js n=100000 path='/../' *** -11.03 % ±1.08% ±1.42% ±1.83%
00:16:45 path/normalize-posix.js n=100000 path='/foo' *** -12.47 % ±0.46% ±0.60% ±0.78%
00:16:45 path/normalize-posix.js n=100000 path='/foo/bar' *** -5.82 % ±0.74% ±0.98% ±1.26%
00:16:45 path/normalize-posix.js n=100000 path='/foo/bar//baz/asdf/quux/..' * -0.73 % ±0.58% ±0.76% ±0.98%
00:16:45 path/normalize-win32.js n=100000 path='.' *** -9.51 % ±1.40% ±1.85% ±2.38%
00:16:45 path/normalize-win32.js n=100000 path='' *** -15.65 % ±1.36% ±1.80% ±2.31%
00:16:45 path/normalize-win32.js n=100000 path='C:\\\\..\\\\' *** -6.19 % ±1.01% ±1.33% ±1.71%
00:16:45 path/normalize-win32.js n=100000 path='C:\\\\foo' *** -6.86 % ±0.96% ±1.26% ±1.62%
00:16:45 path/normalize-win32.js n=100000 path='C:\\\\foo\\\\bar' *** -5.55 % ±0.88% ±1.16% ±1.49%
00:16:45 path/normalize-win32.js n=100000 path='C:\\\\foo\\\\bar\\\\\\\\baz\\\\asdf\\\\quux\\\\..' *** -2.20 % ±0.62% ±0.81% ±1.04%
00:16:45 path/parse-posix.js n=100000 path='' *** -15.52 % ±1.31% ±1.73% ±2.23%
00:16:45 path/parse-posix.js n=100000 path='/' *** -13.87 % ±0.94% ±1.25% ±1.60%
00:16:45 path/parse-posix.js n=100000 path='/foo' *** -12.18 % ±0.83% ±1.10% ±1.42%
00:16:45 path/parse-posix.js n=100000 path='/foo/bar.baz' *** -3.80 % ±1.35% ±1.79% ±2.31%
00:16:45 path/parse-posix.js n=100000 path='/foo/bar/baz/asdf/.quux' *** -7.80 % ±1.31% ±1.73% ±2.22%
00:16:45 path/parse-posix.js n=100000 path='foo/.bar.baz' -0.84 % ±1.43% ±1.89% ±2.44%
00:16:45 path/parse-posix.js n=100000 path='foo/bar' *** -9.94 % ±0.77% ±1.01% ±1.31%
00:16:45 path/parse-win32.js n=100000 path='' *** -14.42 % ±1.28% ±1.69% ±2.17%
00:16:45 path/parse-win32.js n=100000 path='\\\\foo' *** -7.94 % ±0.93% ±1.22% ±1.57%
00:16:45 path/parse-win32.js n=100000 path='\\\\foo\\\\bar\\\\baz\\\\asdf\\\\.quux' *** -8.25 % ±1.60% ±2.12% ±2.72%
00:16:45 path/parse-win32.js n=100000 path='C:\\\\' *** -11.99 % ±1.17% ±1.55% ±1.99%
00:16:45 path/parse-win32.js n=100000 path='C:\\\\foo' *** -11.01 % ±0.96% ±1.27% ±1.64%
00:16:45 path/parse-win32.js n=100000 path='E:\\\\foo\\\\bar.baz' *** -7.39 % ±1.20% ±1.59% ±2.04%
00:16:45 path/parse-win32.js n=100000 path='foo\\\\.bar.baz' *** -6.38 % ±1.15% ±1.52% ±1.95%
00:16:45 path/parse-win32.js n=100000 path='foo\\\\bar' *** -8.37 % ±1.34% ±1.76% ±2.27%
00:16:45 path/relative-posix.js n=100000 paths='/|/' *** -26.78 % ±0.95% ±1.25% ±1.61%
00:16:45 path/relative-posix.js n=100000 paths='/|/var' *** -20.41 % ±0.59% ±0.78% ±1.00%
00:16:45 path/relative-posix.js n=100000 paths='/data/orandea/test/aaa|/data/orandea/impl/bbb' *** -7.77 % ±0.26% ±0.35% ±0.45%
00:16:45 path/relative-posix.js n=100000 paths='/foo/bar/baz/quux|/' *** -8.79 % ±0.23% ±0.30% ±0.38%
00:16:45 path/relative-posix.js n=100000 paths='/foo/bar/baz/quux|/foo/bar/baz/quux' *** -18.01 % ±1.98% ±2.62% ±3.37%
00:16:45 path/relative-posix.js n=100000 paths='/foo/bar/baz/quux|/var/log' *** -8.13 % ±0.24% ±0.31% ±0.40%
00:16:45 path/relative-posix.js n=100000 paths='/var|/bin' *** -14.60 % ±0.35% ±0.46% ±0.60%
00:16:45 path/relative-win32.js n=100000 paths='C:\\\\|D:\\\\' *** -15.54 % ±0.79% ±1.05% ±1.34%
00:16:45 path/relative-win32.js n=100000 paths='C:\\\\foo\\\\bar\\\\baz\\\\quux|C:\\\\' *** -4.45 % ±0.54% ±0.71% ±0.91%
00:16:45 path/relative-win32.js n=100000 paths='C:\\\\foo\\\\bar\\\\baz|C:\\\\foo\\\\bar\\\\baz' *** -13.06 % ±2.18% ±2.88% ±3.71%
00:16:45 path/relative-win32.js n=100000 paths='C:\\\\foo\\\\BAR\\\\BAZ|C:\\\\foo\\\\bar\\\\baz' *** -5.72 % ±0.33% ±0.44% ±0.56%
00:16:45 path/relative-win32.js n=100000 paths='C:\\\\orandea\\\\test\\\\aaa|C:\\\\orandea\\\\impl\\\\bbb' *** -3.19 % ±0.21% ±0.28% ±0.36%
00:16:45 path/resolve-posix.js n=100000 paths='' *** -4.00 % ±0.52% ±0.69% ±0.89%
00:16:45 path/resolve-posix.js n=100000 paths='|' *** -5.76 % ±0.53% ±0.69% ±0.89%
00:16:45 path/resolve-posix.js n=100000 paths='a/b/c/|../../..' -0.26 % ±0.48% ±0.63% ±0.81%
00:16:45 path/resolve-posix.js n=100000 paths='foo/bar|/tmp/file/|..|a/../subfile' *** -3.02 % ±0.65% ±0.86% ±1.11%
00:16:45 path/resolve-win32.js n=100000 paths='' *** -3.72 % ±0.52% ±0.69% ±0.89%
00:16:45 path/resolve-win32.js n=100000 paths='|' *** -5.68 % ±0.55% ±0.72% ±0.93%
00:16:45 path/resolve-win32.js n=100000 paths='c:/blah\\\\blah|d:/games|c:../a' *** -5.75 % ±0.47% ±0.63% ±0.81%
00:16:45 path/resolve-win32.js n=100000 paths='c:/ignore|d:\\\\a/b\\\\c/d|\\\\e.exe' *** -7.96 % ±1.01% ±1.33% ±1.71%
00:16:45 path/toNamespacedPath-posix.js n=100000 path='.' *** -79.53 % ±0.88% ±1.16% ±1.50%
00:16:45 path/toNamespacedPath-posix.js n=100000 path='' *** -79.71 % ±1.12% ±1.49% ±1.92%
00:16:45 path/toNamespacedPath-posix.js n=100000 path='/home/node/..' *** -79.21 % ±0.66% ±0.87% ±1.13%
00:16:45 path/toNamespacedPath-posix.js n=100000 path='/tmp/bar' *** -79.35 % ±0.54% ±0.72% ±0.92%
00:16:45 path/toNamespacedPath-posix.js n=100000 path='/w/bnch-comp/node/benchmark' *** -79.31 % ±0.64% ±0.85% ±1.10%
00:16:45 path/toNamespacedPath-posix.js n=100000 path='bar/baz' *** -78.92 % ±1.15% ±1.52% ±1.96%
00:16:45 path/toNamespacedPath-win32.js n=100000 path='' *** -68.07 % ±1.45% ±1.91% ±2.47%
00:16:45 path/toNamespacedPath-win32.js n=100000 path='\\\\e.exe' *** -10.52 % ±1.16% ±1.53% ±1.97%
00:16:45 path/toNamespacedPath-win32.js n=100000 path='\\\\w\\\\bnch-comp\\\\node\\\\benchmark' *** -3.06 % ±0.56% ±0.74% ±0.95%
00:16:45 path/toNamespacedPath-win32.js n=100000 path='c:../a' *** -2.87 % ±0.31% ±0.40% ±0.52%
00:16:45 path/toNamespacedPath-win32.js n=100000 path='c:/blah\\\\blah' *** -7.68 % ±0.53% ±0.70% ±0.91%
00:16:45 path/toNamespacedPath-win32.js n=100000 path='c:/ignore' *** -10.49 % ±1.06% ±1.40% ±1.80%
00:16:45 path/toNamespacedPath-win32.js n=100000 path='d:/games' *** -12.96 % ±0.95% ±1.25% ±1.60%
00:16:45 path/toNamespacedPath-win32.js n=100000 path='d:\\\\a/b\\\\c/d' *** -6.92 % ±0.84% ±1.11% ±1.42%
I make a few changes for performance, and here are my benchmark results:
path/basename-posix.js n=100000 pathext='' * -3.78 % ±3.43% ±4.56% ±5.94%
path/basename-posix.js n=100000 pathext='/' ** -3.49 % ±2.49% ±3.32% ±4.32%
path/basename-posix.js n=100000 pathext='/foo' -0.84 % ±4.88% ±6.49% ±8.45%
path/basename-posix.js n=100000 pathext='/foo/.bar.baz' -1.75 % ±2.36% ±3.13% ±4.08%
path/basename-posix.js n=100000 pathext='/foo/.bar.baz|.baz' * -3.93 % ±3.18% ±4.25% ±5.59%
path/basename-posix.js n=100000 pathext='/foo/bar/baz/asdf/quux.html' 0.57 % ±3.17% ±4.24% ±5.56%
path/basename-posix.js n=100000 pathext='/foo/bar/baz/asdf/quux.html|.html' 0.21 % ±2.54% ±3.38% ±4.41%
path/basename-posix.js n=100000 pathext='foo' -1.25 % ±5.31% ±7.06% ±9.19%
path/basename-posix.js n=100000 pathext='foo/bar.' ** -2.22 % ±1.45% ±1.93% ±2.51%
path/basename-posix.js n=100000 pathext='foo/bar.|.' 0.25 % ±3.29% ±4.38% ±5.73%
path/basename-win32.js n=100000 pathext='' 1.60 % ±4.22% ±5.63% ±7.36%
path/basename-win32.js n=100000 pathext='\\\\foo\\\\bar\\\\baz\\\\asdf\\\\quux.html' 2.79 % ±3.57% ±4.77% ±6.24%
path/basename-win32.js n=100000 pathext='\\\\foo\\\\bar\\\\baz\\\\asdf\\\\quux.html|.html' 1.20 % ±3.89% ±5.20% ±6.80%
path/basename-win32.js n=100000 pathext='C:\\\\' -1.49 % ±4.13% ±5.49% ±7.15%
path/basename-win32.js n=100000 pathext='C:\\\\foo' -0.32 % ±4.62% ±6.16% ±8.02%
path/basename-win32.js n=100000 pathext='D:\\\\foo\\\\.bar.baz' -1.30 % ±3.06% ±4.08% ±5.33%
path/basename-win32.js n=100000 pathext='E:\\\\foo\\\\.bar.baz|.baz' -1.32 % ±3.22% ±4.29% ±5.59%
path/basename-win32.js n=100000 pathext='foo' -0.52 % ±3.65% ±4.85% ±6.32%
path/basename-win32.js n=100000 pathext='foo\\\\bar.' -0.01 % ±4.24% ±5.65% ±7.39%
path/basename-win32.js n=100000 pathext='foo\\\\bar.|.' -0.52 % ±3.73% ±4.98% ±6.50%
path/dirname-posix.js n=100000 path='' -1.90 % ±4.16% ±5.54% ±7.21%
path/dirname-posix.js n=100000 path='/' -4.29 % ±4.58% ±6.10% ±7.96%
path/dirname-posix.js n=100000 path='/foo' -3.94 % ±5.21% ±6.93% ±9.03%
path/dirname-posix.js n=100000 path='/foo/bar' -1.59 % ±3.90% ±5.21% ±6.82%
path/dirname-posix.js n=100000 path='/foo/bar/baz/asdf/quux' 0.76 % ±3.64% ±4.87% ±6.40%
path/dirname-posix.js n=100000 path='foo' -2.93 % ±5.68% ±7.57% ±9.89%
path/dirname-posix.js n=100000 path='foo/bar' -0.14 % ±3.59% ±4.79% ±6.26%
path/dirname-win32.js n=100000 path='' -2.24 % ±3.17% ±4.21% ±5.49%
path/dirname-win32.js n=100000 path='\\\\' * -4.20 % ±4.00% ±5.33% ±6.94%
path/dirname-win32.js n=100000 path='\\\\foo' -2.72 % ±4.89% ±6.50% ±8.47%
path/dirname-win32.js n=100000 path='C:\\\\foo\\\\bar' -2.55 % ±4.37% ±5.82% ±7.58%
path/dirname-win32.js n=100000 path='D:\\\\foo\\\\bar\\\\baz\\\\asdf\\\\quux' -3.15 % ±3.41% ±4.55% ±5.94%
path/dirname-win32.js n=100000 path='foo' 0.15 % ±3.71% ±4.95% ±6.48%
path/dirname-win32.js n=100000 path='foo\\\\bar' -1.99 % ±4.33% ±5.78% ±7.55%
path/extname-posix.js n=100000 path='' -5.53 % ±6.23% ±8.31% ±10.87%
path/extname-posix.js n=100000 path='/' * -5.05 % ±4.81% ±6.41% ±8.34%
path/extname-posix.js n=100000 path='/foo' *** -7.83 % ±3.80% ±5.05% ±6.58%
path/extname-posix.js n=100000 path='/foo/bar/baz/asdf/quux.foobarbazasdfquux' -3.72 % ±4.64% ±6.24% ±8.24%
path/extname-posix.js n=100000 path='/foo/bar/baz/asdf/quux' * -5.59 % ±4.35% ±5.79% ±7.53%
path/extname-posix.js n=100000 path='foo/.bar.baz' * 4.59 % ±4.12% ±5.49% ±7.15%
path/extname-posix.js n=100000 path='foo/bar/...baz.quux' 2.66 % ±2.92% ±3.91% ±5.16%
path/extname-posix.js n=100000 path='foo/bar/..baz.quux' 3.02 % ±3.18% ±4.23% ±5.51%
path/extname-posix.js n=100000 path='index.html' 0.45 % ±3.45% ±4.59% ±5.97%
path/extname-posix.js n=100000 path='index' -4.42 % ±4.57% ±6.09% ±7.95%
path/extname-win32.js n=100000 path='' -2.56 % ±5.21% ±6.94% ±9.04%
path/extname-win32.js n=100000 path='\\\\' 1.74 % ±6.86% ±9.17% ±12.04%
path/extname-win32.js n=100000 path='\\\\foo\\\\bar\\\\baz\\\\asdf\\\\quux.foobarbazasdfquux' 1.30 % ±2.11% ±2.81% ±3.66%
path/extname-win32.js n=100000 path='C:\\\\foo' -4.58 % ±4.74% ±6.35% ±8.33%
path/extname-win32.js n=100000 path='D:\\\\foo\\\\bar\\\\baz\\\\asdf\\\\quux' 1.80 % ±2.08% ±2.77% ±3.61%
path/extname-win32.js n=100000 path='foo\\\\.bar.baz' -1.54 % ±4.52% ±6.02% ±7.85%
path/extname-win32.js n=100000 path='foo\\\\bar\\\\...baz.quux' -2.59 % ±3.49% ±4.67% ±6.13%
path/extname-win32.js n=100000 path='foo\\\\bar\\\\..baz.quux' 1.76 % ±2.66% ±3.57% ±4.69%
path/extname-win32.js n=100000 path='index.html' * 3.53 % ±2.80% ±3.74% ±4.88%
path/extname-win32.js n=100000 path='index' -1.58 % ±3.27% ±4.35% ±5.67%
path/format-posix.js n=1000000 props='/|/home/user/dir|index.html|.html|index' -0.18 % ±1.86% ±2.48% ±3.23%
path/format-win32.js n=1000000 props='C:\\\\|C:\\\\path\\\\dir|index.html|.html|index' * -1.36 % ±1.15% ±1.52% ±1.98%
path/isAbsolute-posix.js n=100000 path='.' *** -7.12 % ±3.94% ±5.25% ±6.84%
path/isAbsolute-posix.js n=100000 path='' *** -5.73 % ±2.54% ±3.39% ±4.41%
path/isAbsolute-posix.js n=100000 path='/baz/..' -3.94 % ±4.57% ±6.08% ±7.91%
path/isAbsolute-posix.js n=100000 path='/foo/bar' * -4.33 % ±4.07% ±5.42% ±7.06%
path/isAbsolute-posix.js n=100000 path='bar/baz' *** -4.65 % ±2.51% ±3.34% ±4.35%
path/isAbsolute-win32.js n=100000 path='.' -2.60 % ±4.01% ±5.35% ±7.00%
path/isAbsolute-win32.js n=100000 path='' 0.10 % ±4.71% ±6.27% ±8.17%
path/isAbsolute-win32.js n=100000 path='//server' -3.61 % ±4.76% ±6.34% ±8.26%
path/isAbsolute-win32.js n=100000 path='bar\\\\baz' ** -4.06 % ±2.69% ±3.58% ±4.67%
path/isAbsolute-win32.js n=100000 path='C:\\\\baz\\\\..' * -3.59 % ±2.73% ±3.63% ±4.73%
path/isAbsolute-win32.js n=100000 path='C:baz\\\\..' -1.93 % ±2.51% ±3.34% ±4.35%
path/join-posix.js n=100000 paths='/foo|bar||baz/asdf|quux|..' ** 2.70 % ±1.79% ±2.39% ±3.13%
path/join-win32.js n=100000 paths='C:\\\\foo|bar||baz\\\\asdf|quux|..' 1.01 % ±3.64% ±4.86% ±6.36%
path/makeLong-win32.js n=100000 path='\\\\\\\\?\\\\foo' 0.08 % ±4.36% ±5.82% ±7.63%
path/makeLong-win32.js n=100000 path='\\\\\\\\foo\\\\bar' 1.62 % ±2.88% ±3.84% ±5.02%
path/makeLong-win32.js n=100000 path='C:\\\\foo' -1.80 % ±3.12% ±4.16% ±5.41%
path/makeLong-win32.js n=100000 path='foo\\\\bar' -0.17 % ±2.17% ±2.91% ±3.82%
path/normalize-posix.js n=100000 path='.' -2.19 % ±3.50% ±4.66% ±6.08%
path/normalize-posix.js n=100000 path='' -1.76 % ±4.79% ±6.38% ±8.30%
path/normalize-posix.js n=100000 path='/../' *** -4.53 % ±2.58% ±3.44% ±4.49%
path/normalize-posix.js n=100000 path='/foo' -2.35 % ±4.93% ±6.57% ±8.56%
path/normalize-posix.js n=100000 path='/foo/bar' -2.50 % ±3.18% ±4.25% ±5.55%
path/normalize-posix.js n=100000 path='/foo/bar//baz/asdf/quux/..' 2.27 % ±3.21% ±4.27% ±5.57%
path/normalize-win32.js n=100000 path='.' -2.14 % ±3.25% ±4.34% ±5.68%
path/normalize-win32.js n=100000 path='' ** -6.23 % ±4.14% ±5.52% ±7.20%
path/normalize-win32.js n=100000 path='C:\\\\..\\\\' -0.63 % ±1.97% ±2.62% ±3.41%
path/normalize-win32.js n=100000 path='C:\\\\foo' ** -2.13 % ±1.46% ±1.94% ±2.53%
path/normalize-win32.js n=100000 path='C:\\\\foo\\\\bar' -0.95 % ±1.00% ±1.33% ±1.74%
path/normalize-win32.js n=100000 path='C:\\\\foo\\\\bar\\\\\\\\baz\\\\asdf\\\\quux\\\\..' 0.87 % ±3.55% ±4.72% ±6.15%
path/parse-posix.js n=100000 path='' 1.11 % ±3.97% ±5.31% ±6.96%
path/parse-posix.js n=100000 path='/' -2.91 % ±3.74% ±4.99% ±6.52%
path/parse-posix.js n=100000 path='/foo' 0.36 % ±2.55% ±3.40% ±4.45%
path/parse-posix.js n=100000 path='/foo/bar.baz' 0.99 % ±1.24% ±1.66% ±2.17%
path/parse-posix.js n=100000 path='/foo/bar/baz/asdf/.quux' -1.29 % ±3.79% ±5.05% ±6.58%
path/parse-posix.js n=100000 path='foo/.bar.baz' -1.22 % ±2.09% ±2.78% ±3.62%
path/parse-posix.js n=100000 path='foo/bar' ** -3.83 % ±2.27% ±3.02% ±3.93%
path/parse-win32.js n=100000 path='' -3.57 % ±3.63% ±4.85% ±6.35%
path/parse-win32.js n=100000 path='\\\\foo' -1.17 % ±2.00% ±2.66% ±3.46%
path/parse-win32.js n=100000 path='\\\\foo\\\\bar\\\\baz\\\\asdf\\\\.quux' -1.86 % ±2.35% ±3.13% ±4.10%
path/parse-win32.js n=100000 path='C:\\\\' -1.12 % ±2.98% ±3.98% ±5.22%
path/parse-win32.js n=100000 path='C:\\\\foo' * -3.49 % ±3.14% ±4.17% ±5.43%
path/parse-win32.js n=100000 path='E:\\\\foo\\\\bar.baz' 1.21 % ±3.25% ±4.37% ±5.79%
path/parse-win32.js n=100000 path='foo\\\\.bar.baz' ** -2.33 % ±1.58% ±2.10% ±2.75%
path/parse-win32.js n=100000 path='foo\\\\bar' -1.26 % ±2.20% ±2.94% ±3.83%
path/relative-posix.js n=100000 paths='/|/' -2.97 % ±3.06% ±4.08% ±5.32%
path/relative-posix.js n=100000 paths='/|/var' *** -4.88 % ±1.90% ±2.53% ±3.30%
path/relative-posix.js n=100000 paths='/data/orandea/test/aaa|/data/orandea/impl/bbb' * -1.07 % ±0.91% ±1.21% ±1.58%
path/relative-posix.js n=100000 paths='/foo/bar/baz/quux|/' -0.24 % ±0.64% ±0.86% ±1.12%
path/relative-posix.js n=100000 paths='/foo/bar/baz/quux|/foo/bar/baz/quux' * 2.63 % ±2.07% ±2.77% ±3.64%
path/relative-posix.js n=100000 paths='/foo/bar/baz/quux|/var/log' -0.27 % ±0.74% ±0.99% ±1.29%
path/relative-posix.js n=100000 paths='/var|/bin' *** -4.18 % ±1.28% ±1.71% ±2.24%
path/relative-win32.js n=100000 paths='C:\\\\|D:\\\\' -1.54 % ±1.87% ±2.49% ±3.24%
path/relative-win32.js n=100000 paths='C:\\\\foo\\\\bar\\\\baz\\\\quux|C:\\\\' 0.79 % ±2.04% ±2.74% ±3.62%
path/relative-win32.js n=100000 paths='C:\\\\foo\\\\bar\\\\baz|C:\\\\foo\\\\bar\\\\baz' ** 5.18 % ±3.50% ±4.69% ±6.17%
path/relative-win32.js n=100000 paths='C:\\\\foo\\\\BAR\\\\BAZ|C:\\\\foo\\\\bar\\\\baz' 1.41 % ±1.63% ±2.18% ±2.87%
path/relative-win32.js n=100000 paths='C:\\\\orandea\\\\test\\\\aaa|C:\\\\orandea\\\\impl\\\\bbb' -0.82 % ±1.00% ±1.33% ±1.73%
path/resolve-posix.js n=100000 paths='' 2.68 % ±2.88% ±3.84% ±5.01%
path/resolve-posix.js n=100000 paths='|' 0.14 % ±1.08% ±1.44% ±1.88%
path/resolve-posix.js n=100000 paths='a/b/c/|../../..' * 1.83 % ±1.50% ±2.01% ±2.63%
path/resolve-posix.js n=100000 paths='foo/bar|/tmp/file/|..|a/../subfile' *** 3.04 % ±1.04% ±1.38% ±1.80%
path/resolve-win32.js n=100000 paths='' -0.40 % ±1.51% ±2.02% ±2.63%
path/resolve-win32.js n=100000 paths='|' 0.50 % ±0.96% ±1.27% ±1.66%
path/resolve-win32.js n=100000 paths='c:/blah\\\\blah|d:/games|c:../a' *** 1.82 % ±0.90% ±1.19% ±1.55%
path/resolve-win32.js n=100000 paths='c:/ignore|d:\\\\a/b\\\\c/d|\\\\e.exe' -0.70 % ±2.65% ±3.56% ±4.71%
path/toNamespacedPath-posix.js n=100000 path='.' *** -18.37 % ±5.04% ±6.71% ±8.74%
path/toNamespacedPath-posix.js n=100000 path='' *** -18.13 % ±4.36% ±5.81% ±7.56%
path/toNamespacedPath-posix.js n=100000 path='/home/aviv/Documents/projects/node/node-path-urls/benchmark' *** -20.22 % ±3.67% ±4.89% ±6.38%
path/toNamespacedPath-posix.js n=100000 path='/home/node/..' *** -19.64 % ±3.06% ±4.07% ±5.30%
path/toNamespacedPath-posix.js n=100000 path='/tmp/bar' *** -18.34 % ±3.95% ±5.25% ±6.84%
path/toNamespacedPath-posix.js n=100000 path='bar/baz' *** -18.41 % ±4.28% ±5.71% ±7.44%
path/toNamespacedPath-win32.js n=100000 path='' 0.83 % ±4.37% ±5.82% ±7.57%
path/toNamespacedPath-win32.js n=100000 path='\\\\e.exe' * -2.09 % ±1.70% ±2.26% ±2.94%
path/toNamespacedPath-win32.js n=100000 path='\\\\home\\\\aviv\\\\Documents\\\\projects\\\\node\\\\node-path-urls\\\\benchmark' ** -1.49 % ±0.92% ±1.23% ±1.60%
path/toNamespacedPath-win32.js n=100000 path='c:../a' * 1.29 % ±1.16% ±1.55% ±2.02%
path/toNamespacedPath-win32.js n=100000 path='c:/blah\\\\blah' *** -3.37 % ±1.46% ±1.94% ±2.55%
path/toNamespacedPath-win32.js n=100000 path='c:/ignore' ** -4.41 % ±2.92% ±3.91% ±5.15%
path/toNamespacedPath-win32.js n=100000 path='d:/games' 0.49 % ±1.45% ±1.94% ±2.52%
path/toNamespacedPath-win32.js n=100000 path='d:\\\\a/b\\\\c/d' * -2.25 % ±1.73% ±2.31% ±3.01%
Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1535/
While the performance impact seems significant, I don't think it'll be noticeable (but I haven't tested it yet for the actual MS timings). It's just an extra typeof check.
As @LiviaMedeiros said, I could also make an internal function for it to be used in the internals.
Can we run the benchmarks of file system operations? I don't think 20% is a cost that is acceptable.
fs benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1541/
Results
confidence improvement accuracy (*) (**) (***)
fs/bench_fdatasyncSync.js n=10000 type='existing' -1.23 % ±3.32% ±4.47% ±5.91%
fs/bench_fdatasyncSync.js n=10000 type='non-existing' 1.53 % ±3.01% ±4.01% ±5.21%
fs/bench-accessSync.js n=100000 type='existing' ** -0.55 % ±0.37% ±0.50% ±0.65%
fs/bench-accessSync.js n=100000 type='non-existing' ** -0.59 % ±0.39% ±0.51% ±0.67%
fs/bench-accessSync.js n=100000 type='non-flat-existing' *** -1.19 % ±0.54% ±0.72% ±0.94%
fs/bench-chmodSync.js n=1000 type='existing' -0.77 % ±1.32% ±1.75% ±2.27%
fs/bench-chmodSync.js n=1000 type='non-existing' -0.65 % ±3.54% ±4.71% ±6.13%
fs/bench-chownSync.js n=10000 method='chownSync' type='existing' -0.83 % ±3.07% ±4.09% ±5.32%
fs/bench-chownSync.js n=10000 method='chownSync' type='non-existing' -0.46 % ±1.19% ±1.58% ±2.05%
fs/bench-chownSync.js n=10000 method='lchownSync' type='existing' -1.61 % ±3.33% ±4.43% ±5.76%
fs/bench-chownSync.js n=10000 method='lchownSync' type='non-existing' 0.17 % ±1.90% ±2.52% ±3.28%
fs/bench-copyFileSync.js n=10000 type='invalid' -0.21 % ±1.47% ±1.95% ±2.54%
fs/bench-copyFileSync.js n=10000 type='valid' -0.12 % ±2.17% ±2.89% ±3.77%
fs/bench-existsSync.js n=1000000 type='existing' 0.01 % ±0.62% ±0.82% ±1.07%
fs/bench-existsSync.js n=1000000 type='non-existing' -0.46 % ±0.58% ±0.77% ±1.00%
fs/bench-existsSync.js n=1000000 type='non-flat-existing' -0.34 % ±0.53% ±0.71% ±0.92%
fs/bench-fchmodSync.js n=1000 type='existing' -4.09 % ±10.26% ±13.77% ±18.16%
fs/bench-fchmodSync.js n=1000 type='non-existing' -0.21 % ±4.23% ±5.63% ±7.32%
fs/bench-fsyncSync.js n=10000 type='existing' -0.22 % ±0.25% ±0.33% ±0.43%
fs/bench-fsyncSync.js n=10000 type='non-existing' -1.67 % ±3.15% ±4.18% ±5.44%
fs/bench-ftruncateSync.js n=10000 type='invalid' -0.37 % ±1.65% ±2.19% ±2.85%
fs/bench-ftruncateSync.js n=10000 type='valid' 1.48 % ±3.99% ±5.30% ±6.89%
fs/bench-linkSync.js n=1000 type='invalid' 1.10 % ±4.59% ±6.10% ±7.94%
fs/bench-linkSync.js n=1000 type='valid' * 4.18 % ±3.58% ±4.76% ±6.20%
fs/bench-mkdirp.js n=10000 * -22.03 % ±18.58% ±24.70% ±32.12%
fs/bench-mkdirSync.js n=1000 recursive='false' type='existing' 1.05 % ±3.25% ±4.33% ±5.64%
fs/bench-mkdirSync.js n=1000 recursive='false' type='non-existing' -5.59 % ±12.80% ±17.01% ±22.12%
fs/bench-mkdirSync.js n=1000 recursive='true' type='existing' 1.87 % ±3.08% ±4.10% ±5.34%
fs/bench-mkdirSync.js n=1000 recursive='true' type='non-existing' 1.90 % ±11.93% ±15.87% ±20.62%
fs/bench-mkdtempSync.js n=10000 type='invalid' -1.67 % ±1.81% ±2.42% ±3.17%
fs/bench-mkdtempSync.js n=10000 type='valid-buffer' -2.31 % ±9.48% ±12.60% ±16.38%
fs/bench-mkdtempSync.js n=10000 type='valid-string' 2.64 % ±9.75% ±12.96% ±16.85%
fs/bench-opendir.js bufferSize=1024 mode='async' dir='lib' n=100 -3.89 % ±4.22% ±5.62% ±7.33%
fs/bench-opendir.js bufferSize=1024 mode='async' dir='test/parallel' n=100 -0.20 % ±0.63% ±0.84% ±1.10%
fs/bench-opendir.js bufferSize=1024 mode='callback' dir='lib' n=100 -0.20 % ±2.08% ±2.76% ±3.59%
fs/bench-opendir.js bufferSize=1024 mode='callback' dir='test/parallel' n=100 -2.80 % ±14.35% ±19.08% ±24.80%
fs/bench-opendir.js bufferSize=1024 mode='sync' dir='lib' n=100 -1.28 % ±1.56% ±2.07% ±2.70%
fs/bench-opendir.js bufferSize=1024 mode='sync' dir='test/parallel' n=100 -0.04 % ±0.64% ±0.85% ±1.11%
fs/bench-opendir.js bufferSize=32 mode='async' dir='lib' n=100 -1.60 % ±3.19% ±4.24% ±5.53%
fs/bench-opendir.js bufferSize=32 mode='async' dir='test/parallel' n=100 0.18 % ±0.64% ±0.85% ±1.10%
fs/bench-opendir.js bufferSize=32 mode='callback' dir='lib' n=100 -0.37 % ±1.77% ±2.35% ±3.06%
fs/bench-opendir.js bufferSize=32 mode='callback' dir='test/parallel' n=100 1.98 % ±2.52% ±3.35% ±4.36%
fs/bench-opendir.js bufferSize=32 mode='sync' dir='lib' n=100 -0.29 % ±1.13% ±1.50% ±1.95%
fs/bench-opendir.js bufferSize=32 mode='sync' dir='test/parallel' n=100 ** -0.64 % ±0.43% ±0.57% ±0.75%
fs/bench-opendir.js bufferSize=4 mode='async' dir='lib' n=100 0.11 % ±1.61% ±2.14% ±2.79%
fs/bench-opendir.js bufferSize=4 mode='async' dir='test/parallel' n=100 -0.09 % ±0.64% ±0.85% ±1.10%
fs/bench-opendir.js bufferSize=4 mode='callback' dir='lib' n=100 -0.80 % ±1.39% ±1.85% ±2.41%
fs/bench-opendir.js bufferSize=4 mode='callback' dir='test/parallel' n=100 -0.71 % ±0.80% ±1.06% ±1.38%
fs/bench-opendir.js bufferSize=4 mode='sync' dir='lib' n=100 -1.55 % ±1.61% ±2.15% ±2.79%
fs/bench-opendir.js bufferSize=4 mode='sync' dir='test/parallel' n=100 *** -1.67 % ±0.34% ±0.46% ±0.60%
fs/bench-opendirSync.js n=1000 type='existing' -0.04 % ±0.42% ±0.57% ±0.74%
fs/bench-opendirSync.js n=1000 type='non-existing' 0.75 % ±4.46% ±5.93% ±7.71%
fs/bench-openSync.js n=100000 type='existing' * 0.76 % ±0.68% ±0.91% ±1.18%
fs/bench-openSync.js n=100000 type='non-existing' -0.06 % ±0.43% ±0.57% ±0.74%
fs/bench-readdir.js withFileTypes='false' dir='lib' n=10 3.13 % ±10.01% ±13.30% ±17.29%
fs/bench-readdir.js withFileTypes='false' dir='test/parallel' n=10 2.55 % ±8.29% ±11.03% ±14.34%
fs/bench-readdir.js withFileTypes='true' dir='lib' n=10 1.98 % ±11.27% ±15.01% ±19.57%
fs/bench-readdir.js withFileTypes='true' dir='test/parallel' n=10 0.25 % ±6.94% ±9.24% ±12.03%
fs/bench-readdirSync.js withFileTypes='false' dir='lib' n=10 -0.12 % ±3.13% ±4.16% ±5.41%
fs/bench-readdirSync.js withFileTypes='false' dir='test/parallel' n=10 1.63 % ±3.17% ±4.23% ±5.51%
fs/bench-readdirSync.js withFileTypes='true' dir='lib' n=10 -0.85 % ±3.30% ±4.39% ±5.71%
fs/bench-readdirSync.js withFileTypes='true' dir='test/parallel' n=10 -0.68 % ±2.87% ±3.82% ±4.98%
fs/bench-readlinkSync.js n=1000 type='invalid' -2.76 % ±4.17% ±5.54% ±7.21%
fs/bench-readlinkSync.js n=1000 type='valid' 0.77 % ±1.93% ±2.57% ±3.36%
fs/bench-readSync.js n=10000 type='existing' 2.56 % ±2.78% ±3.73% ±4.90%
fs/bench-readSync.js n=10000 type='non-existing' 0.01 % ±0.92% ±1.23% ±1.60%
fs/bench-readvSync.js n=100000 type='invalid' 0.33 % ±0.57% ±0.75% ±0.98%
fs/bench-readvSync.js n=100000 type='valid' 0.51 % ±1.20% ±1.60% ±2.08%
fs/bench-realpath.js pathType='relative' n=10000 0.42 % ±1.07% ±1.42% ±1.85%
fs/bench-realpath.js pathType='resolved' n=10000 0.48 % ±1.01% ±1.34% ±1.75%
fs/bench-realpathSync.js pathType='relative' n=10000 ** -1.27 % ±0.85% ±1.14% ±1.48%
fs/bench-realpathSync.js pathType='resolved' n=10000 -0.48 % ±1.72% ±2.28% ±2.97%
fs/bench-renameSync.js n=2000 type='invalid' * -3.82 % ±3.66% ±4.88% ±6.37%
fs/bench-renameSync.js n=2000 type='valid' 0.34 % ±0.51% ±0.68% ±0.88%
fs/bench-rmdirSync.js n=10000 type='existing' -3.30 % ±4.38% ±5.87% ±7.73%
fs/bench-rmdirSync.js n=10000 type='non-existing' 0.83 % ±1.15% ±1.53% ±1.99%
fs/bench-stat-promise.js statType='fstat' n=200000 -0.54 % ±0.99% ±1.32% ±1.72%
fs/bench-stat-promise.js statType='lstat' n=200000 -0.23 % ±1.09% ±1.45% ±1.89%
fs/bench-stat-promise.js statType='stat' n=200000 -0.56 % ±0.97% ±1.29% ±1.68%
fs/bench-stat.js statType='fstat' n=200000 0.61 % ±1.37% ±1.83% ±2.38%
fs/bench-stat.js statType='lstat' n=200000 -0.69 % ±1.09% ±1.45% ±1.88%
fs/bench-stat.js statType='stat' n=200000 0.42 % ±1.23% ±1.63% ±2.12%
fs/bench-statSync-failure.js throwType='noThrow' statSyncType='lstatSync' n=10000 -1.31 % ±3.03% ±4.03% ±5.24%
fs/bench-statSync-failure.js throwType='noThrow' statSyncType='statSync' n=10000 0.34 % ±3.84% ±5.11% ±6.67%
fs/bench-statSync-failure.js throwType='throw' statSyncType='fstatSync' n=10000 0.17 % ±0.96% ±1.28% ±1.67%
fs/bench-statSync-failure.js throwType='throw' statSyncType='lstatSync' n=10000 0.68 % ±2.20% ±2.93% ±3.81%
fs/bench-statSync-failure.js throwType='throw' statSyncType='statSync' n=10000 1.51 % ±1.61% ±2.14% ±2.79%
fs/bench-statSync.js statSyncType='fstatSync' n=10000 -0.34 % ±2.33% ±3.09% ±4.02%
fs/bench-statSync.js statSyncType='lstatSync' n=10000 0.95 % ±3.20% ±4.26% ±5.54%
fs/bench-statSync.js statSyncType='statSync' n=10000 0.07 % ±1.57% ±2.09% ±2.73%
fs/bench-symlinkSync.js n=1000 type='invalid' 0.71 % ±3.61% ±4.80% ±6.24%
fs/bench-symlinkSync.js n=1000 type='valid' -0.80 % ±3.41% ±4.53% ±5.89%
fs/bench-timesSync.js n=1000 func='futimes' type='existing' -0.50 % ±5.05% ±6.71% ±8.72%
fs/bench-timesSync.js n=1000 func='futimes' type='non-existing' 1.75 % ±3.37% ±4.49% ±5.83%
fs/bench-timesSync.js n=1000 func='lutimes' type='existing' 0.10 % ±1.07% ±1.42% ±1.84%
fs/bench-timesSync.js n=1000 func='lutimes' type='non-existing' -0.47 % ±3.27% ±4.35% ±5.66%
fs/bench-timesSync.js n=1000 func='utimes' type='existing' 0.06 % ±0.94% ±1.25% ±1.63%
fs/bench-timesSync.js n=1000 func='utimes' type='non-existing' -1.15 % ±4.98% ±6.62% ±8.61%
fs/bench-unlinkSync.js n=1000 type='existing' -0.46 % ±0.66% ±0.88% ±1.15%
fs/bench-unlinkSync.js n=1000 type='non-existing' 1.24 % ±2.60% ±3.47% ±4.54%
fs/bench-writeFileSync.js n=1000 func='writeFile' useBuffer='false' length=1024 useFd='false' encoding='utf8' -13.17 % ±17.59% ±23.39% ±30.44%
fs/bench-writeFileSync.js n=1000 func='writeFile' useBuffer='false' length=1024 useFd='true' encoding='utf8' -0.09 % ±2.82% ±3.76% ±4.90%
fs/bench-writeFileSync.js n=1000 func='writeFile' useBuffer='false' length=102400 useFd='false' encoding='utf8' 1.16 % ±10.89% ±14.49% ±18.86%
fs/bench-writeFileSync.js n=1000 func='writeFile' useBuffer='false' length=102400 useFd='true' encoding='utf8' 0.57 % ±0.99% ±1.31% ±1.71%
fs/bench-writeFileSync.js n=1000 func='writeFile' useBuffer='false' length=1048576 useFd='false' encoding='utf8' 0.75 % ±17.97% ±23.89% ±31.06%
fs/bench-writeFileSync.js n=1000 func='writeFile' useBuffer='false' length=1048576 useFd='true' encoding='utf8' 0.21 % ±0.28% ±0.38% ±0.50%
fs/bench-writevSync.js n=100000 type='invalid' -0.04 % ±0.52% ±0.69% ±0.90%
fs/bench-writevSync.js n=100000 type='valid' * 0.73 % ±0.67% ±0.90% ±1.17%
fs/read-stream-throughput.js n=1024 highWaterMark=1024 filesize=1024000 encodingType='asc' * -0.74 % ±0.72% ±0.96% ±1.24%
fs/read-stream-throughput.js n=1024 highWaterMark=1024 filesize=1024000 encodingType='buf' -0.43 % ±0.98% ±1.30% ±1.69%
fs/read-stream-throughput.js n=1024 highWaterMark=1024 filesize=1024000 encodingType='utf' 0.01 % ±0.48% ±0.64% ±0.84%
fs/read-stream-throughput.js n=1024 highWaterMark=1048576 filesize=1024000 encodingType='asc' 0.82 % ±3.71% ±4.93% ±6.41%
fs/read-stream-throughput.js n=1024 highWaterMark=1048576 filesize=1024000 encodingType='buf' -20.09 % ±24.06% ±32.01% ±41.67%
fs/read-stream-throughput.js n=1024 highWaterMark=1048576 filesize=1024000 encodingType='utf' 0.02 % ±0.08% ±0.10% ±0.14%
fs/read-stream-throughput.js n=1024 highWaterMark=4096 filesize=1024000 encodingType='asc' * -0.63 % ±0.57% ±0.76% ±0.99%
fs/read-stream-throughput.js n=1024 highWaterMark=4096 filesize=1024000 encodingType='buf' -0.68 % ±1.41% ±1.87% ±2.44%
fs/read-stream-throughput.js n=1024 highWaterMark=4096 filesize=1024000 encodingType='utf' 0.11 % ±0.60% ±0.80% ±1.04%
fs/read-stream-throughput.js n=1024 highWaterMark=65535 filesize=1024000 encodingType='asc' 0.06 % ±2.06% ±2.73% ±3.55%
fs/read-stream-throughput.js n=1024 highWaterMark=65535 filesize=1024000 encodingType='buf' -2.08 % ±11.12% ±14.79% ±19.23%
fs/read-stream-throughput.js n=1024 highWaterMark=65535 filesize=1024000 encodingType='utf' -0.11 % ±0.40% ±0.53% ±0.69%
fs/readfile-partitioned.js concurrent=1 len=1024 encoding='' duration=5 0.00 % ±0.35% ±0.46% ±0.60%
fs/readfile-partitioned.js concurrent=1 len=1024 encoding='utf-8' duration=5 -0.19 % ±0.30% ±0.40% ±0.52%
fs/readfile-partitioned.js concurrent=1 len=16777216 encoding='' duration=5 0.10 % ±0.24% ±0.31% ±0.41%
fs/readfile-partitioned.js concurrent=1 len=16777216 encoding='utf-8' duration=5 0.77 % ±0.79% ±1.06% ±1.38%
fs/readfile-partitioned.js concurrent=10 len=1024 encoding='' duration=5 0.03 % ±0.74% ±0.99% ±1.29%
fs/readfile-partitioned.js concurrent=10 len=1024 encoding='utf-8' duration=5 -0.12 % ±1.01% ±1.34% ±1.74%
fs/readfile-partitioned.js concurrent=10 len=16777216 encoding='' duration=5 -0.54 % ±1.07% ±1.42% ±1.85%
fs/readfile-partitioned.js concurrent=10 len=16777216 encoding='utf-8' duration=5 -0.07 % ±0.23% ±0.30% ±0.39%
fs/readfile-permission-enabled.js concurrent=1 len=1024 encoding='' duration=5 0.61 % ±1.36% ±1.81% ±2.36%
fs/readfile-permission-enabled.js concurrent=1 len=1024 encoding='utf-8' duration=5 0.06 % ±1.52% ±2.02% ±2.63%
fs/readfile-permission-enabled.js concurrent=1 len=16777216 encoding='' duration=5 24.73 % ±34.05% ±45.33% ±59.05%
fs/readfile-permission-enabled.js concurrent=1 len=16777216 encoding='utf-8' duration=5 -0.01 % ±0.46% ±0.62% ±0.80%
fs/readfile-permission-enabled.js concurrent=10 len=1024 encoding='' duration=5 -0.20 % ±0.68% ±0.90% ±1.17%
fs/readfile-permission-enabled.js concurrent=10 len=1024 encoding='utf-8' duration=5 0.06 % ±0.77% ±1.02% ±1.33%
fs/readfile-permission-enabled.js concurrent=10 len=16777216 encoding='' duration=5 0.06 % ±1.96% ±2.61% ±3.39%
fs/readfile-permission-enabled.js concurrent=10 len=16777216 encoding='utf-8' duration=5 -0.26 % ±0.30% ±0.39% ±0.51%
fs/readfile-promises.js concurrent=1 len=1024 encoding='' duration=5 -0.14 % ±0.52% ±0.69% ±0.90%
fs/readfile-promises.js concurrent=1 len=1024 encoding='utf-8' duration=5 * 0.61 % ±0.51% ±0.68% ±0.88%
fs/readfile-promises.js concurrent=1 len=16777216 encoding='' duration=5 4.94 % ±20.11% ±26.75% ±34.78%
fs/readfile-promises.js concurrent=1 len=16777216 encoding='utf-8' duration=5 0.15 % ±0.26% ±0.34% ±0.44%
fs/readfile-promises.js concurrent=1 len=33554432 encoding='' duration=5 -0.23 % ±0.37% ±0.49% ±0.64%
fs/readfile-promises.js concurrent=1 len=33554432 encoding='utf-8' duration=5 0.06 % ±0.21% ±0.28% ±0.37%
fs/readfile-promises.js concurrent=1 len=4194304 encoding='' duration=5 -18.61 % ±27.55% ±36.68% ±47.76%
fs/readfile-promises.js concurrent=1 len=4194304 encoding='utf-8' duration=5 0.03 % ±0.26% ±0.34% ±0.44%
fs/readfile-promises.js concurrent=1 len=524288 encoding='' duration=5 5.79 % ±6.33% ±8.42% ±10.94%
fs/readfile-promises.js concurrent=1 len=524288 encoding='utf-8' duration=5 -0.14 % ±0.49% ±0.65% ±0.84%
fs/readfile-promises.js concurrent=1 len=8388608 encoding='' duration=5 -12.68 % ±26.92% ±35.79% ±46.52%
fs/readfile-promises.js concurrent=1 len=8388608 encoding='utf-8' duration=5 0.05 % ±0.23% ±0.31% ±0.41%
fs/readfile-promises.js concurrent=10 len=1024 encoding='' duration=5 1.19 % ±1.78% ±2.37% ±3.08%
fs/readfile-promises.js concurrent=10 len=1024 encoding='utf-8' duration=5 1.47 % ±2.34% ±3.11% ±4.04%
fs/readfile-promises.js concurrent=10 len=16777216 encoding='' duration=5 -0.44 % ±0.91% ±1.21% ±1.57%
fs/readfile-promises.js concurrent=10 len=16777216 encoding='utf-8' duration=5 * 0.21 % ±0.20% ±0.26% ±0.34%
fs/readfile-promises.js concurrent=10 len=33554432 encoding='' duration=5 0.46 % ±0.77% ±1.03% ±1.34%
fs/readfile-promises.js concurrent=10 len=33554432 encoding='utf-8' duration=5 * 0.17 % ±0.16% ±0.21% ±0.27%
fs/readfile-promises.js concurrent=10 len=4194304 encoding='' duration=5 -1.46 % ±1.72% ±2.29% ±2.98%
fs/readfile-promises.js concurrent=10 len=4194304 encoding='utf-8' duration=5 0.11 % ±0.32% ±0.43% ±0.56%
fs/readfile-promises.js concurrent=10 len=524288 encoding='' duration=5 3.15 % ±6.62% ±8.80% ±11.44%
fs/readfile-promises.js concurrent=10 len=524288 encoding='utf-8' duration=5 -0.12 % ±0.48% ±0.63% ±0.82%
fs/readfile-promises.js concurrent=10 len=8388608 encoding='' duration=5 -0.19 % ±0.99% ±1.32% ±1.72%
fs/readfile-promises.js concurrent=10 len=8388608 encoding='utf-8' duration=5 -0.07 % ±0.21% ±0.28% ±0.37%
fs/readfile.js concurrent=1 len=1024 encoding='' duration=5 -0.44 % ±1.49% ±1.98% ±2.58%
fs/readfile.js concurrent=1 len=1024 encoding='utf-8' duration=5 * -1.77 % ±1.48% ±1.97% ±2.56%
fs/readfile.js concurrent=1 len=16777216 encoding='' duration=5 -2.92 % ±29.62% ±39.38% ±51.19%
fs/readfile.js concurrent=1 len=16777216 encoding='utf-8' duration=5 -0.13 % ±0.49% ±0.65% ±0.85%
fs/readfile.js concurrent=10 len=1024 encoding='' duration=5 * -0.84 % ±0.78% ±1.04% ±1.35%
fs/readfile.js concurrent=10 len=1024 encoding='utf-8' duration=5 0.10 % ±0.87% ±1.16% ±1.51%
fs/readfile.js concurrent=10 len=16777216 encoding='' duration=5 * 2.32 % ±1.79% ±2.38% ±3.09%
fs/readfile.js concurrent=10 len=16777216 encoding='utf-8' duration=5 -0.06 % ±0.22% ±0.29% ±0.38%
fs/readFileSync.js n=10000 hasFileDescriptor='false' path='existing' encoding='undefined' 0.42 % ±0.97% ±1.30% ±1.69%
fs/readFileSync.js n=10000 hasFileDescriptor='false' path='existing' encoding='utf8' -1.26 % ±2.09% ±2.78% ±3.64%
fs/readFileSync.js n=10000 hasFileDescriptor='false' path='non-existing' encoding='undefined' 0.13 % ±1.35% ±1.80% ±2.34%
fs/readFileSync.js n=10000 hasFileDescriptor='false' path='non-existing' encoding='utf8' 0.10 % ±1.07% ±1.43% ±1.86%
fs/readFileSync.js n=10000 hasFileDescriptor='true' path='existing' encoding='undefined' 0.58 % ±2.54% ±3.38% ±4.40%
fs/readFileSync.js n=10000 hasFileDescriptor='true' path='existing' encoding='utf8' -2.21 % ±2.60% ±3.46% ±4.50%
fs/readFileSync.js n=10000 hasFileDescriptor='true' path='non-existing' encoding='undefined' -1.05 % ±2.48% ±3.29% ±4.28%
fs/readFileSync.js n=10000 hasFileDescriptor='true' path='non-existing' encoding='utf8' 0.24 % ±2.06% ±2.74% ±3.56%
fs/write-stream-throughput.js size=1024 encodingType='asc' dur=5 -8.63 % ±11.00% ±14.63% ±19.02%
fs/write-stream-throughput.js size=1024 encodingType='buf' dur=5 -4.67 % ±12.79% ±17.01% ±22.11%
fs/write-stream-throughput.js size=1024 encodingType='utf' dur=5 -0.07 % ±0.64% ±0.85% ±1.11%
fs/write-stream-throughput.js size=1048576 encodingType='asc' dur=5 -16.13 % ±17.05% ±22.93% ±30.33%
fs/write-stream-throughput.js size=1048576 encodingType='buf' dur=5 0.08 % ±21.28% ±28.30% ±36.79%
fs/write-stream-throughput.js size=1048576 encodingType='utf' dur=5 0.13 % ±0.76% ±1.02% ±1.32%
fs/write-stream-throughput.js size=2 encodingType='asc' dur=5 -0.14 % ±0.55% ±0.74% ±0.96%
fs/write-stream-throughput.js size=2 encodingType='buf' dur=5 -0.04 % ±0.23% ±0.30% ±0.39%
fs/write-stream-throughput.js size=2 encodingType='utf' dur=5 -0.17 % ±0.63% ±0.84% ±1.10%
fs/write-stream-throughput.js size=65535 encodingType='asc' dur=5 -4.76 % ±6.39% ±8.50% ±11.06%
fs/write-stream-throughput.js size=65535 encodingType='buf' dur=5 1.00 % ±6.70% ±8.92% ±11.59%
fs/write-stream-throughput.js size=65535 encodingType='utf' dur=5 0.55 % ±0.76% ±1.02% ±1.32%
fs/writefile-promises.js concurrent=1 size=1024 encodingType='asc' duration=5 -0.23 % ±1.16% ±1.54% ±2.01%
fs/writefile-promises.js concurrent=1 size=1024 encodingType='buf' duration=5 -0.37 % ±1.53% ±2.03% ±2.65%
fs/writefile-promises.js concurrent=1 size=1024 encodingType='utf' duration=5 0.18 % ±1.10% ±1.46% ±1.89%
fs/writefile-promises.js concurrent=1 size=1048576 encodingType='asc' duration=5 15.51 % ±31.87% ±42.38% ±55.11%
fs/writefile-promises.js concurrent=1 size=1048576 encodingType='buf' duration=5 -7.46 % ±15.13% ±20.11% ±26.15%
fs/writefile-promises.js concurrent=1 size=1048576 encodingType='utf' duration=5 -1.27 % ±1.36% ±1.81% ±2.37%
fs/writefile-promises.js concurrent=1 size=2 encodingType='asc' duration=5 -0.67 % ±1.23% ±1.64% ±2.13%
fs/writefile-promises.js concurrent=1 size=2 encodingType='buf' duration=5 -0.67 % ±1.53% ±2.03% ±2.64%
fs/writefile-promises.js concurrent=1 size=2 encodingType='utf' duration=5 * 1.19 % ±1.09% ±1.44% ±1.88%
fs/writefile-promises.js concurrent=1 size=65535 encodingType='asc' duration=5 -1.15 % ±15.51% ±20.62% ±26.81%
fs/writefile-promises.js concurrent=1 size=65535 encodingType='buf' duration=5 * -11.01 % ±10.43% ±13.88% ±18.07%
fs/writefile-promises.js concurrent=1 size=65535 encodingType='utf' duration=5 -0.21 % ±1.22% ±1.63% ±2.12%
fs/writefile-promises.js concurrent=10 size=1024 encodingType='asc' duration=5 -0.29 % ±1.21% ±1.61% ±2.10%
fs/writefile-promises.js concurrent=10 size=1024 encodingType='buf' duration=5 0.56 % ±1.09% ±1.45% ±1.89%
fs/writefile-promises.js concurrent=10 size=1024 encodingType='utf' duration=5 -0.13 % ±1.03% ±1.37% ±1.79%
fs/writefile-promises.js concurrent=10 size=1048576 encodingType='asc' duration=5 -0.28 % ±2.32% ±3.08% ±4.01%
fs/writefile-promises.js concurrent=10 size=1048576 encodingType='buf' duration=5 1.13 % ±2.44% ±3.24% ±4.21%
fs/writefile-promises.js concurrent=10 size=1048576 encodingType='utf' duration=5 -0.61 % ±1.26% ±1.68% ±2.20%
fs/writefile-promises.js concurrent=10 size=2 encodingType='asc' duration=5 0.72 % ±1.07% ±1.42% ±1.85%
fs/writefile-promises.js concurrent=10 size=2 encodingType='buf' duration=5 0.31 % ±1.28% ±1.71% ±2.23%
fs/writefile-promises.js concurrent=10 size=2 encodingType='utf' duration=5 0.16 % ±1.16% ±1.54% ±2.01%
fs/writefile-promises.js concurrent=10 size=65535 encodingType='asc' duration=5 0.44 % ±1.60% ±2.12% ±2.76%
fs/writefile-promises.js concurrent=10 size=65535 encodingType='buf' duration=5 0.24 % ±1.94% ±2.58% ±3.36%
fs/writefile-promises.js concurrent=10 size=65535 encodingType='utf' duration=5 ** -2.09 % ±1.42% ±1.89% ±2.46%
FWIW 20% was observed only for path.posix.toNamespacedPath() which is literally noop.
@anonrig, given the benchmark results, do you think a secondary system w/o URL support should be added for the toNamespacedPath function?
I'm -0.5 since benchmarks seem to have some impact, but I'd like to raise awareness before unblocking.
cc @nodejs/tsc @nodejs/performance wdyt?
Should we add an error hint where if someone calls a path method with a string URL (not an URL instance) we suggest that they wrap their input in
new URL? Basically if we’re about to throw anyway, if the input started withfile:then enrich the error with this suggestion.
IIRC It's possible for a file path to contain the file: string, so an error like that would be unnecessary
I suspect this will thrown when using permission model
CI: https://ci.nodejs.org/job/node-test-pull-request/58910/
I suspect this will thrown when using permission model
I don't think that'll happen, as it's doing all the changes before any path processing really occurs