diff options
Diffstat (limited to 'benchmark/path/isAbsolute.js')
-rw-r--r-- | benchmark/path/isAbsolute.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/benchmark/path/isAbsolute.js b/benchmark/path/isAbsolute.js new file mode 100644 index 00000000000..c9489fe85cb --- /dev/null +++ b/benchmark/path/isAbsolute.js @@ -0,0 +1,27 @@ +var common = require('../common.js'); +var path = require('path'); + +var bench = common.createBenchmark(main, { + type: ['win32', 'posix'], + n: [1e6], +}); + +function main(conf) { + var n = +conf.n; + var p = path[conf.type]; + var tests = conf.type === 'win32' + ? ['//server', 'C:\\baz\\..', 'bar\\baz', '.'] + : ['/foo/bar', '/baz/..', 'bar/baz', '.']; + + bench.start(); + for (var i = 0; i < n; i++) { + runTests(p, tests); + } + bench.end(n); +} + +function runTests(p, tests) { + for (var i = 0; i < tests.length; i++) { + p.isAbsolute(tests[i]); + } +} |