forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelative.js
More file actions
33 lines (27 loc) · 781 Bytes
/
relative.js
File metadata and controls
33 lines (27 loc) · 781 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
var common = require('../common.js');
var path = require('path');
var v8 = require('v8');
var bench = common.createBenchmark(main, {
type: ['win32', 'posix'],
n: [1e5],
});
function main(conf) {
var n = +conf.n;
var runTest = conf.type === 'win32' ? runWin32Test : runPosixTest;
// Force optimization before starting the benchmark
runTest();
v8.setFlagsFromString('--allow_natives_syntax');
eval('%OptimizeFunctionOnNextCall(path[conf.type].relative)');
runTest();
bench.start();
for (var i = 0; i < n; i++) {
runTest();
}
bench.end(n);
}
function runWin32Test() {
path.win32.relative('C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb');
}
function runPosixTest() {
path.posix.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb');
}