mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
0d15161c24
Path functions being benchmarked are: * format * isAbsolute * join * normalize * relative * resolve PR-URL: https://github.com/nodejs/io.js/pull/1778 Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
28 lines
561 B
JavaScript
28 lines
561 B
JavaScript
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]);
|
|
}
|
|
}
|