forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathisAbsolute.js
More file actions
34 lines (29 loc) · 796 Bytes
/
isAbsolute.js
File metadata and controls
34 lines (29 loc) · 796 Bytes
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
var common = require('../common.js');
var path = require('path');
var v8 = require('v8');
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', '.'];
// Force optimization before starting the benchmark
p.isAbsolute(tests[0]);
v8.setFlagsFromString('--allow_natives_syntax');
eval('%OptimizeFunctionOnNextCall(p.isAbsolute)');
p.isAbsolute(tests[0]);
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]);
}
}