2016-02-20 01:03:16 +00:00
|
|
|
'use strict';
|
2017-09-14 01:48:53 +00:00
|
|
|
const common = require('../common.js');
|
|
|
|
const path = require('path');
|
2015-07-04 19:50:07 +00:00
|
|
|
|
2017-09-14 01:48:53 +00:00
|
|
|
const bench = common.createBenchmark(main, {
|
2016-02-06 03:23:29 +00:00
|
|
|
path: [
|
|
|
|
'',
|
|
|
|
'/',
|
|
|
|
'/foo',
|
|
|
|
'/foo/bar.baz',
|
|
|
|
'foo/.bar.baz',
|
|
|
|
'foo/bar',
|
|
|
|
'/foo/bar/baz/asdf/.quux'
|
|
|
|
],
|
|
|
|
n: [1e6]
|
2015-07-04 19:50:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
function main(conf) {
|
2017-09-14 01:48:53 +00:00
|
|
|
const n = +conf.n;
|
|
|
|
const p = path.posix;
|
|
|
|
const input = String(conf.path);
|
2015-07-04 19:50:07 +00:00
|
|
|
|
|
|
|
for (var i = 0; i < n; i++) {
|
2016-02-06 03:23:29 +00:00
|
|
|
p.parse(input);
|
2015-07-04 19:50:07 +00:00
|
|
|
}
|
2017-03-01 11:37:12 +00:00
|
|
|
bench.start();
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
p.parse(input);
|
|
|
|
}
|
2015-07-04 19:50:07 +00:00
|
|
|
bench.end(n);
|
|
|
|
}
|