-
Notifications
You must be signed in to change notification settings - Fork 1
/
benchmark.js
37 lines (28 loc) · 1004 Bytes
/
benchmark.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env node
"use strict";
/* eslint-disable no-console */
let isResolvedPosix = require("./").isResolvedPosix;
let isResolvedWin32 = require("./").isResolvedWin32;
let path = require("path");
let n = 1000000;
console.time("isResolvedPosix");
for (let i = 0; i < n; i++) {
if (!isResolvedPosix("/foo/bar/baz")) throw "never happens";
}
console.timeEnd("isResolvedPosix");
console.time("isResolvedWin32");
for (let i = 0; i < n; i++) {
if (!isResolvedWin32("c:\\foo\\bar\\baz")) throw "never happens";
}
console.timeEnd("isResolvedWin32");
// "Can't we just unconditionally call path.resolve on any absolute path name?"
console.time("path.posix.resolve");
for (let i = 0; i < n; i++) {
if (path.posix.resolve("/foo/bar/baz") === "x") throw "never happens";
}
console.timeEnd("path.posix.resolve");
console.time("path.win32.resolve");
for (let i = 0; i < n; i++) {
if (path.win32.resolve("c:\\foo\\bar\\baz") === "x") throw "never happens";
}
console.timeEnd("path.win32.resolve");