summaryrefslogtreecommitdiff
path: root/benchmark/path/parse-win32.js
blob: 7746a10b797a36cd25d95f94e60775f8962c93ab (plain)
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
var common = require('../common.js');
var path = require('path');
var v8 = require('v8');

var bench = common.createBenchmark(main, {
  path: [
    '',
    'C:\\',
    'C:\\foo',
    '\\foo',
    'E:\\foo\\bar.baz',
    'foo\\.bar.baz',
    'foo\\bar',
    '\\foo\\bar\\baz\\asdf\\.quux'
  ],
  n: [1e6]
});

function main(conf) {
  var n = +conf.n;
  var p = path.win32;
  var input = '' + conf.path;

  // Force optimization before starting the benchmark
  p.parse(input);
  v8.setFlagsFromString('--allow_natives_syntax');
  eval('%OptimizeFunctionOnNextCall(p.parse)');
  p.parse(input);

  bench.start();
  for (var i = 0; i < n; i++) {
    p.parse(input);
  }
  bench.end(n);
}