2016-02-20 02:03:16 +01:00
|
|
|
'use strict';
|
2017-09-14 03:48:53 +02:00
|
|
|
const common = require('../common.js');
|
2018-01-23 13:14:21 +01:00
|
|
|
const { win32 } = require('path');
|
2016-02-06 04:23:29 +01:00
|
|
|
|
2017-09-14 03:48:53 +02:00
|
|
|
const bench = common.createBenchmark(main, {
|
2016-02-06 04:23:29 +01:00
|
|
|
pathext: [
|
|
|
|
'',
|
|
|
|
'C:\\',
|
|
|
|
'C:\\foo',
|
|
|
|
'D:\\foo\\.bar.baz',
|
2016-02-25 07:30:10 +01:00
|
|
|
['E:\\foo\\.bar.baz', '.baz'].join('|'),
|
2016-02-06 04:23:29 +01:00
|
|
|
'foo',
|
|
|
|
'foo\\bar.',
|
|
|
|
['foo\\bar.', '.'].join('|'),
|
|
|
|
'\\foo\\bar\\baz\\asdf\\quux.html',
|
|
|
|
['\\foo\\bar\\baz\\asdf\\quux.html', '.html'].join('|')
|
|
|
|
],
|
|
|
|
n: [1e6]
|
|
|
|
});
|
|
|
|
|
2017-12-30 03:57:01 +01:00
|
|
|
function main({ n, pathext }) {
|
2016-02-06 04:23:29 +01:00
|
|
|
var ext;
|
2017-12-30 03:57:01 +01:00
|
|
|
const extIdx = pathext.indexOf('|');
|
2016-02-06 04:23:29 +01:00
|
|
|
if (extIdx !== -1) {
|
2017-12-30 03:57:01 +01:00
|
|
|
ext = pathext.slice(extIdx + 1);
|
|
|
|
pathext = pathext.slice(0, extIdx);
|
2016-02-06 04:23:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bench.start();
|
|
|
|
for (var i = 0; i < n; i++) {
|
2018-01-23 13:14:21 +01:00
|
|
|
win32.basename(pathext, ext);
|
2016-02-06 04:23:29 +01:00
|
|
|
}
|
|
|
|
bench.end(n);
|
|
|
|
}
|