2016-02-20 09:03:16 +08:00
|
|
|
'use strict';
|
2017-09-14 09:48:53 +08:00
|
|
|
const common = require('../common.js');
|
2017-12-30 10:57:01 +08:00
|
|
|
const { win32 } = require('path');
|
2015-06-06 08:43:48 +08:00
|
|
|
|
2017-09-14 09:48:53 +08:00
|
|
|
const bench = common.createBenchmark(main, {
|
2016-02-06 11:23:29 +08:00
|
|
|
paths: [
|
|
|
|
'',
|
|
|
|
['', ''].join('|'),
|
|
|
|
['c:/ignore', 'd:\\a/b\\c/d', '\\e.exe'].join('|'),
|
2019-02-05 14:06:08 +08:00
|
|
|
['c:/blah\\blah', 'd:/games', 'c:../a'].join('|'),
|
2016-02-06 11:23:29 +08:00
|
|
|
],
|
2018-12-30 07:26:36 +08:00
|
|
|
n: [1e5]
|
2015-06-06 08:43:48 +08:00
|
|
|
});
|
|
|
|
|
2017-12-30 10:57:01 +08:00
|
|
|
function main({ n, paths }) {
|
|
|
|
const args = paths.split('|');
|
2018-12-30 07:26:36 +08:00
|
|
|
const copy = [...args];
|
|
|
|
const orig = copy[0];
|
2015-06-06 08:43:48 +08:00
|
|
|
|
|
|
|
bench.start();
|
|
|
|
for (var i = 0; i < n; i++) {
|
2018-12-30 07:26:36 +08:00
|
|
|
if (i % 3 === 0) {
|
|
|
|
copy[0] = `${orig}${i}`;
|
|
|
|
win32.resolve(...copy);
|
|
|
|
} else {
|
|
|
|
win32.resolve(...args);
|
|
|
|
}
|
2015-06-06 08:43:48 +08:00
|
|
|
}
|
|
|
|
bench.end(n);
|
|
|
|
}
|