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