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-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',
|
2019-02-05 06:06:08 +00:00
|
|
|
'/foo/bar/baz/asdf/.quux',
|
2016-02-06 03:23:29 +00:00
|
|
|
],
|
|
|
|
n: [1e6]
|
2015-07-04 19:50:07 +00:00
|
|
|
});
|
|
|
|
|
2017-12-30 02:57:01 +00:00
|
|
|
function main({ n, path }) {
|
2015-07-04 19:50:07 +00:00
|
|
|
for (var i = 0; i < n; i++) {
|
2017-12-30 02:57:01 +00:00
|
|
|
posix.parse(path);
|
2015-07-04 19:50:07 +00:00
|
|
|
}
|
2017-03-01 11:37:12 +00:00
|
|
|
bench.start();
|
|
|
|
for (i = 0; i < n; i++) {
|
2017-12-30 02:57:01 +00:00
|
|
|
posix.parse(path);
|
2017-03-01 11:37:12 +00:00
|
|
|
}
|
2015-07-04 19:50:07 +00:00
|
|
|
bench.end(n);
|
|
|
|
}
|