• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common.js');
3const { win32 } = require('path');
4
5const bench = common.createBenchmark(main, {
6  paths: [
7    '',
8    ['', ''].join('|'),
9    ['c:/ignore', 'd:\\a/b\\c/d', '\\e.exe'].join('|'),
10    ['c:/blah\\blah', 'd:/games', 'c:../a'].join('|'),
11  ],
12  n: [1e5],
13});
14
15function main({ n, paths }) {
16  const args = paths.split('|');
17  const copy = [...args];
18  const orig = copy[0];
19
20  bench.start();
21  for (let i = 0; i < n; i++) {
22    if (i % 3 === 0) {
23      copy[0] = `${orig}${i}`;
24      win32.resolve(...copy);
25    } else {
26      win32.resolve(...args);
27    }
28  }
29  bench.end(n);
30}
31