2016-02-20 02:03:16 +01:00
|
|
|
'use strict';
|
2017-09-14 03:48:53 +02:00
|
|
|
const common = require('../common.js');
|
|
|
|
const path = require('path');
|
2015-06-06 02:43:48 +02:00
|
|
|
|
2017-09-14 03:48:53 +02:00
|
|
|
const bench = common.createBenchmark(main, {
|
2016-02-06 04:23:29 +01:00
|
|
|
props: [
|
|
|
|
['/', '/home/user/dir', 'index.html', '.html', 'index'].join('|')
|
|
|
|
],
|
|
|
|
n: [1e7]
|
2015-06-06 02:43:48 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
function main(conf) {
|
2017-09-14 03:48:53 +02:00
|
|
|
const n = +conf.n;
|
|
|
|
const p = path.posix;
|
|
|
|
const props = String(conf.props).split('|');
|
|
|
|
const obj = {
|
2016-02-06 04:23:29 +01:00
|
|
|
root: props[0] || '',
|
|
|
|
dir: props[1] || '',
|
|
|
|
base: props[2] || '',
|
|
|
|
ext: props[3] || '',
|
|
|
|
name: props[4] || '',
|
2015-06-06 02:43:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
bench.start();
|
|
|
|
for (var i = 0; i < n; i++) {
|
2016-02-06 04:23:29 +01:00
|
|
|
p.format(obj);
|
2015-06-06 02:43:48 +02:00
|
|
|
}
|
|
|
|
bench.end(n);
|
|
|
|
}
|