benchmark: (path) use destructuring
PR-URL: https://github.com/nodejs/node/pull/18250 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
32b3cad576
commit
92953fa194
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { posix } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
pathext: [
|
pathext: [
|
||||||
@ -18,20 +18,17 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, pathext }) {
|
||||||
const n = +conf.n;
|
|
||||||
const p = path.posix;
|
|
||||||
var input = String(conf.pathext);
|
|
||||||
var ext;
|
var ext;
|
||||||
const extIdx = input.indexOf('|');
|
const extIdx = pathext.indexOf('|');
|
||||||
if (extIdx !== -1) {
|
if (extIdx !== -1) {
|
||||||
ext = input.slice(extIdx + 1);
|
ext = pathext.slice(extIdx + 1);
|
||||||
input = input.slice(0, extIdx);
|
pathext = pathext.slice(0, extIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.basename(input, ext);
|
posix.basename(pathext, ext);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { posix } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
pathext: [
|
pathext: [
|
||||||
@ -18,20 +18,17 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, pathext }) {
|
||||||
const n = +conf.n;
|
|
||||||
const p = path.win32;
|
|
||||||
var input = String(conf.pathext);
|
|
||||||
var ext;
|
var ext;
|
||||||
const extIdx = input.indexOf('|');
|
const extIdx = pathext.indexOf('|');
|
||||||
if (extIdx !== -1) {
|
if (extIdx !== -1) {
|
||||||
ext = input.slice(extIdx + 1);
|
ext = pathext.slice(extIdx + 1);
|
||||||
input = input.slice(0, extIdx);
|
pathext = pathext.slice(0, extIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.basename(input, ext);
|
posix.basename(pathext, ext);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { posix } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
@ -15,14 +15,10 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, path }) {
|
||||||
const n = +conf.n;
|
|
||||||
const p = path.posix;
|
|
||||||
const input = String(conf.path);
|
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.dirname(input);
|
posix.dirname(path);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { win32 } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
@ -15,14 +15,10 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, path }) {
|
||||||
const n = +conf.n;
|
|
||||||
const p = path.win32;
|
|
||||||
const input = String(conf.path);
|
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.dirname(input);
|
win32.dirname(path);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { posix } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
@ -18,14 +18,10 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, path }) {
|
||||||
const n = +conf.n;
|
|
||||||
const p = path.posix;
|
|
||||||
const input = String(conf.path);
|
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.extname(input);
|
posix.extname(path);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { win32 } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
@ -18,14 +18,10 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, path }) {
|
||||||
const n = +conf.n;
|
|
||||||
const p = path.win32;
|
|
||||||
const input = String(conf.path);
|
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.extname(input);
|
win32.extname(path);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { posix } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
props: [
|
props: [
|
||||||
@ -9,10 +9,8 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e7]
|
n: [1e7]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, props }) {
|
||||||
const n = +conf.n;
|
props = props.split('|');
|
||||||
const p = path.posix;
|
|
||||||
const props = String(conf.props).split('|');
|
|
||||||
const obj = {
|
const obj = {
|
||||||
root: props[0] || '',
|
root: props[0] || '',
|
||||||
dir: props[1] || '',
|
dir: props[1] || '',
|
||||||
@ -23,7 +21,7 @@ function main(conf) {
|
|||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.format(obj);
|
posix.format(obj);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { win32 } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
props: [
|
props: [
|
||||||
@ -9,10 +9,8 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e7]
|
n: [1e7]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, props }) {
|
||||||
const n = +conf.n;
|
props = props.split('|');
|
||||||
const p = path.win32;
|
|
||||||
const props = String(conf.props).split('|');
|
|
||||||
const obj = {
|
const obj = {
|
||||||
root: props[0] || '',
|
root: props[0] || '',
|
||||||
dir: props[1] || '',
|
dir: props[1] || '',
|
||||||
@ -23,7 +21,7 @@ function main(conf) {
|
|||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.format(obj);
|
win32.format(obj);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { posix } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
@ -13,14 +13,10 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, path }) {
|
||||||
const n = +conf.n;
|
|
||||||
const p = path.posix;
|
|
||||||
const input = String(conf.path);
|
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.isAbsolute(input);
|
posix.isAbsolute(path);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { win32 } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
@ -14,14 +14,10 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, path }) {
|
||||||
const n = +conf.n;
|
|
||||||
const p = path.win32;
|
|
||||||
const input = String(conf.path);
|
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.isAbsolute(input);
|
win32.isAbsolute(path);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { posix } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
paths: [
|
paths: [
|
||||||
@ -9,14 +9,12 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, paths }) {
|
||||||
const n = +conf.n;
|
const args = paths.split('|');
|
||||||
const p = path.posix;
|
|
||||||
const args = String(conf.paths).split('|');
|
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.join.apply(null, args);
|
posix.join.apply(null, args);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { win32 } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
paths: [
|
paths: [
|
||||||
@ -9,14 +9,12 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, paths }) {
|
||||||
const n = +conf.n;
|
const args = paths.split('|');
|
||||||
const p = path.win32;
|
|
||||||
const args = String(conf.paths).split('|');
|
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.join.apply(null, args);
|
win32.join.apply(null, args);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { win32 } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
@ -12,14 +12,10 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, path }) {
|
||||||
const n = +conf.n;
|
|
||||||
const p = path.win32;
|
|
||||||
const input = String(conf.path);
|
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p._makeLong(input);
|
win32._makeLong(path);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { posix } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
@ -14,14 +14,10 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, path }) {
|
||||||
const n = +conf.n;
|
|
||||||
const p = path.posix;
|
|
||||||
const input = String(conf.path);
|
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.normalize(input);
|
posix.normalize(path);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { win32 } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
@ -14,14 +14,10 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, path }) {
|
||||||
const n = +conf.n;
|
|
||||||
const p = path.win32;
|
|
||||||
const input = String(conf.path);
|
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.normalize(input);
|
win32.normalize(path);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { posix } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
@ -15,17 +15,13 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, path }) {
|
||||||
const n = +conf.n;
|
|
||||||
const p = path.posix;
|
|
||||||
const input = String(conf.path);
|
|
||||||
|
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.parse(input);
|
posix.parse(path);
|
||||||
}
|
}
|
||||||
bench.start();
|
bench.start();
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
p.parse(input);
|
posix.parse(path);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { win32 } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
path: [
|
path: [
|
||||||
@ -16,17 +16,13 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, path }) {
|
||||||
const n = +conf.n;
|
|
||||||
const p = path.win32;
|
|
||||||
const input = String(conf.path);
|
|
||||||
|
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.parse(input);
|
win32.parse(path);
|
||||||
}
|
}
|
||||||
bench.start();
|
bench.start();
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
p.parse(input);
|
win32.parse(path);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { posix } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
paths: [
|
paths: [
|
||||||
@ -15,23 +15,20 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, paths }) {
|
||||||
const n = +conf.n;
|
|
||||||
const p = path.posix;
|
|
||||||
var from = String(conf.paths);
|
|
||||||
var to = '';
|
var to = '';
|
||||||
const delimIdx = from.indexOf('|');
|
const delimIdx = paths.indexOf('|');
|
||||||
if (delimIdx > -1) {
|
if (delimIdx > -1) {
|
||||||
to = from.slice(delimIdx + 1);
|
to = paths.slice(delimIdx + 1);
|
||||||
from = from.slice(0, delimIdx);
|
paths = paths.slice(0, delimIdx);
|
||||||
}
|
}
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.relative(from, to);
|
posix.relative(paths, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
p.relative(from, to);
|
posix.relative(paths, to);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { win32 } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
paths: [
|
paths: [
|
||||||
@ -13,25 +13,22 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, paths }) {
|
||||||
const n = +conf.n;
|
|
||||||
const p = path.win32;
|
|
||||||
var from = String(conf.paths);
|
|
||||||
var to = '';
|
var to = '';
|
||||||
const delimIdx = from.indexOf('|');
|
const delimIdx = paths.indexOf('|');
|
||||||
if (delimIdx > -1) {
|
if (delimIdx > -1) {
|
||||||
to = from.slice(delimIdx + 1);
|
to = paths.slice(delimIdx + 1);
|
||||||
from = from.slice(0, delimIdx);
|
paths = paths.slice(0, delimIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warmup
|
// Warmup
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.relative(from, to);
|
win32.relative(paths, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
p.relative(from, to);
|
win32.relative(paths, to);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { posix } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
paths: [
|
paths: [
|
||||||
@ -12,14 +12,12 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, paths }) {
|
||||||
const n = +conf.n;
|
const args = paths.split('|');
|
||||||
const p = path.posix;
|
|
||||||
const args = String(conf.paths).split('|');
|
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.resolve.apply(null, args);
|
posix.resolve.apply(null, args);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common.js');
|
const common = require('../common.js');
|
||||||
const path = require('path');
|
const { win32 } = require('path');
|
||||||
|
|
||||||
const bench = common.createBenchmark(main, {
|
const bench = common.createBenchmark(main, {
|
||||||
paths: [
|
paths: [
|
||||||
@ -12,14 +12,12 @@ const bench = common.createBenchmark(main, {
|
|||||||
n: [1e6]
|
n: [1e6]
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(conf) {
|
function main({ n, paths }) {
|
||||||
const n = +conf.n;
|
const args = paths.split('|');
|
||||||
const p = path.win32;
|
|
||||||
const args = String(conf.paths).split('|');
|
|
||||||
|
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
p.resolve.apply(null, args);
|
win32.resolve.apply(null, args);
|
||||||
}
|
}
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user