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
|
|
|
props: [
|
2019-02-05 14:06:08 +08:00
|
|
|
['C:\\', 'C:\\path\\dir', 'index.html', '.html', 'index'].join('|'),
|
2016-02-06 11:23:29 +08:00
|
|
|
],
|
2018-12-30 07:26:36 +08:00
|
|
|
n: [1e6]
|
2015-06-06 08:43:48 +08:00
|
|
|
});
|
|
|
|
|
2017-12-30 10:57:01 +08:00
|
|
|
function main({ n, props }) {
|
|
|
|
props = props.split('|');
|
2017-09-14 09:48:53 +08:00
|
|
|
const obj = {
|
2016-02-06 11:23:29 +08:00
|
|
|
root: props[0] || '',
|
|
|
|
dir: props[1] || '',
|
2018-12-30 07:26:36 +08:00
|
|
|
base: '',
|
2016-02-06 11:23:29 +08:00
|
|
|
ext: props[3] || '',
|
2018-12-30 07:26:36 +08:00
|
|
|
name: '',
|
2015-06-06 08:43:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
bench.start();
|
2019-07-31 21:26:38 +08:00
|
|
|
for (let i = 0; i < n; i++) {
|
2018-12-30 07:26:36 +08:00
|
|
|
obj.base = `a${i}${props[2] || ''}`;
|
|
|
|
obj.name = `a${i}${props[4] || ''}`;
|
2017-12-30 10:57:01 +08:00
|
|
|
win32.format(obj);
|
2015-06-06 08:43:48 +08:00
|
|
|
}
|
|
|
|
bench.end(n);
|
|
|
|
}
|