2016-02-20 01:03:16 +00:00
|
|
|
'use strict';
|
2017-09-14 01:48:53 +00:00
|
|
|
const common = require('../common.js');
|
2017-12-30 02:57:01 +00:00
|
|
|
const { posix } = require('path');
|
2015-06-06 00:43:48 +00:00
|
|
|
|
2017-09-14 01:48:53 +00:00
|
|
|
const bench = common.createBenchmark(main, {
|
2016-02-06 03:23:29 +00:00
|
|
|
paths: [
|
2019-02-05 06:06:08 +00:00
|
|
|
['/foo', 'bar', '', 'baz/asdf', 'quux', '..'].join('|'),
|
2016-02-06 03:23:29 +00:00
|
|
|
],
|
2023-02-14 17:09:42 +00:00
|
|
|
n: [1e5],
|
2015-06-06 00:43:48 +00:00
|
|
|
});
|
|
|
|
|
2017-12-30 02:57:01 +00:00
|
|
|
function main({ n, paths }) {
|
|
|
|
const args = paths.split('|');
|
2018-12-29 23:26:36 +00:00
|
|
|
const copy = [...args];
|
|
|
|
const orig = copy[1];
|
2015-06-06 00:43:48 +00:00
|
|
|
|
|
|
|
bench.start();
|
2019-07-31 13:26:38 +00:00
|
|
|
for (let i = 0; i < n; i++) {
|
2018-12-29 23:26:36 +00:00
|
|
|
if (i % 3 === 0) {
|
|
|
|
copy[1] = `${orig}${i}`;
|
|
|
|
posix.join(...copy);
|
|
|
|
} else {
|
|
|
|
posix.join(...args);
|
|
|
|
}
|
2015-06-06 00:43:48 +00:00
|
|
|
}
|
|
|
|
bench.end(n);
|
|
|
|
}
|