summaryrefslogtreecommitdiff
path: root/benchmark/path
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2017-12-30 03:57:01 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2018-01-23 01:29:24 +0100
commit92953fa1941937a33abc1830fdbd76d8ec091083 (patch)
tree6166165d85d2a0e13ced9f3c752ca4eedf285bbe /benchmark/path
parent32b3cad5760089a691a534fdb72a22905bb70f90 (diff)
downloadandroid-node-v8-92953fa1941937a33abc1830fdbd76d8ec091083.tar.gz
android-node-v8-92953fa1941937a33abc1830fdbd76d8ec091083.tar.bz2
android-node-v8-92953fa1941937a33abc1830fdbd76d8ec091083.zip
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>
Diffstat (limited to 'benchmark/path')
-rw-r--r--benchmark/path/basename-posix.js15
-rw-r--r--benchmark/path/basename-win32.js15
-rw-r--r--benchmark/path/dirname-posix.js10
-rw-r--r--benchmark/path/dirname-win32.js10
-rw-r--r--benchmark/path/extname-posix.js10
-rw-r--r--benchmark/path/extname-win32.js10
-rw-r--r--benchmark/path/format-posix.js10
-rw-r--r--benchmark/path/format-win32.js10
-rw-r--r--benchmark/path/isAbsolute-posix.js10
-rw-r--r--benchmark/path/isAbsolute-win32.js10
-rw-r--r--benchmark/path/join-posix.js10
-rw-r--r--benchmark/path/join-win32.js10
-rw-r--r--benchmark/path/makeLong-win32.js10
-rw-r--r--benchmark/path/normalize-posix.js10
-rw-r--r--benchmark/path/normalize-win32.js10
-rw-r--r--benchmark/path/parse-posix.js12
-rw-r--r--benchmark/path/parse-win32.js12
-rw-r--r--benchmark/path/relative-posix.js17
-rw-r--r--benchmark/path/relative-win32.js17
-rw-r--r--benchmark/path/resolve-posix.js10
-rw-r--r--benchmark/path/resolve-win32.js10
21 files changed, 85 insertions, 153 deletions
diff --git a/benchmark/path/basename-posix.js b/benchmark/path/basename-posix.js
index 42e98c5932..20b734703f 100644
--- a/benchmark/path/basename-posix.js
+++ b/benchmark/path/basename-posix.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { posix } = require('path');
const bench = common.createBenchmark(main, {
pathext: [
@@ -18,20 +18,17 @@ const bench = common.createBenchmark(main, {
n: [1e6]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.posix;
- var input = String(conf.pathext);
+function main({ n, pathext }) {
var ext;
- const extIdx = input.indexOf('|');
+ const extIdx = pathext.indexOf('|');
if (extIdx !== -1) {
- ext = input.slice(extIdx + 1);
- input = input.slice(0, extIdx);
+ ext = pathext.slice(extIdx + 1);
+ pathext = pathext.slice(0, extIdx);
}
bench.start();
for (var i = 0; i < n; i++) {
- p.basename(input, ext);
+ posix.basename(pathext, ext);
}
bench.end(n);
}
diff --git a/benchmark/path/basename-win32.js b/benchmark/path/basename-win32.js
index 6966e4fe81..8a66f56d6e 100644
--- a/benchmark/path/basename-win32.js
+++ b/benchmark/path/basename-win32.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { posix } = require('path');
const bench = common.createBenchmark(main, {
pathext: [
@@ -18,20 +18,17 @@ const bench = common.createBenchmark(main, {
n: [1e6]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.win32;
- var input = String(conf.pathext);
+function main({ n, pathext }) {
var ext;
- const extIdx = input.indexOf('|');
+ const extIdx = pathext.indexOf('|');
if (extIdx !== -1) {
- ext = input.slice(extIdx + 1);
- input = input.slice(0, extIdx);
+ ext = pathext.slice(extIdx + 1);
+ pathext = pathext.slice(0, extIdx);
}
bench.start();
for (var i = 0; i < n; i++) {
- p.basename(input, ext);
+ posix.basename(pathext, ext);
}
bench.end(n);
}
diff --git a/benchmark/path/dirname-posix.js b/benchmark/path/dirname-posix.js
index 98ad67056b..a045125f43 100644
--- a/benchmark/path/dirname-posix.js
+++ b/benchmark/path/dirname-posix.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { posix } = require('path');
const bench = common.createBenchmark(main, {
path: [
@@ -15,14 +15,10 @@ const bench = common.createBenchmark(main, {
n: [1e6]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.posix;
- const input = String(conf.path);
-
+function main({ n, path }) {
bench.start();
for (var i = 0; i < n; i++) {
- p.dirname(input);
+ posix.dirname(path);
}
bench.end(n);
}
diff --git a/benchmark/path/dirname-win32.js b/benchmark/path/dirname-win32.js
index c09a3aff98..f47abdd379 100644
--- a/benchmark/path/dirname-win32.js
+++ b/benchmark/path/dirname-win32.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { win32 } = require('path');
const bench = common.createBenchmark(main, {
path: [
@@ -15,14 +15,10 @@ const bench = common.createBenchmark(main, {
n: [1e6]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.win32;
- const input = String(conf.path);
-
+function main({ n, path }) {
bench.start();
for (var i = 0; i < n; i++) {
- p.dirname(input);
+ win32.dirname(path);
}
bench.end(n);
}
diff --git a/benchmark/path/extname-posix.js b/benchmark/path/extname-posix.js
index 4b6e056094..3dde5e9900 100644
--- a/benchmark/path/extname-posix.js
+++ b/benchmark/path/extname-posix.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { posix } = require('path');
const bench = common.createBenchmark(main, {
path: [
@@ -18,14 +18,10 @@ const bench = common.createBenchmark(main, {
n: [1e6]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.posix;
- const input = String(conf.path);
-
+function main({ n, path }) {
bench.start();
for (var i = 0; i < n; i++) {
- p.extname(input);
+ posix.extname(path);
}
bench.end(n);
}
diff --git a/benchmark/path/extname-win32.js b/benchmark/path/extname-win32.js
index fd54d485a9..55602df34b 100644
--- a/benchmark/path/extname-win32.js
+++ b/benchmark/path/extname-win32.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { win32 } = require('path');
const bench = common.createBenchmark(main, {
path: [
@@ -18,14 +18,10 @@ const bench = common.createBenchmark(main, {
n: [1e6]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.win32;
- const input = String(conf.path);
-
+function main({ n, path }) {
bench.start();
for (var i = 0; i < n; i++) {
- p.extname(input);
+ win32.extname(path);
}
bench.end(n);
}
diff --git a/benchmark/path/format-posix.js b/benchmark/path/format-posix.js
index fe20cc3c4f..aa92c06a4d 100644
--- a/benchmark/path/format-posix.js
+++ b/benchmark/path/format-posix.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { posix } = require('path');
const bench = common.createBenchmark(main, {
props: [
@@ -9,10 +9,8 @@ const bench = common.createBenchmark(main, {
n: [1e7]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.posix;
- const props = String(conf.props).split('|');
+function main({ n, props }) {
+ props = props.split('|');
const obj = {
root: props[0] || '',
dir: props[1] || '',
@@ -23,7 +21,7 @@ function main(conf) {
bench.start();
for (var i = 0; i < n; i++) {
- p.format(obj);
+ posix.format(obj);
}
bench.end(n);
}
diff --git a/benchmark/path/format-win32.js b/benchmark/path/format-win32.js
index e59bee8669..5921f95cf1 100644
--- a/benchmark/path/format-win32.js
+++ b/benchmark/path/format-win32.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { win32 } = require('path');
const bench = common.createBenchmark(main, {
props: [
@@ -9,10 +9,8 @@ const bench = common.createBenchmark(main, {
n: [1e7]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.win32;
- const props = String(conf.props).split('|');
+function main({ n, props }) {
+ props = props.split('|');
const obj = {
root: props[0] || '',
dir: props[1] || '',
@@ -23,7 +21,7 @@ function main(conf) {
bench.start();
for (var i = 0; i < n; i++) {
- p.format(obj);
+ win32.format(obj);
}
bench.end(n);
}
diff --git a/benchmark/path/isAbsolute-posix.js b/benchmark/path/isAbsolute-posix.js
index 956c8e0d13..4299484048 100644
--- a/benchmark/path/isAbsolute-posix.js
+++ b/benchmark/path/isAbsolute-posix.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { posix } = require('path');
const bench = common.createBenchmark(main, {
path: [
@@ -13,14 +13,10 @@ const bench = common.createBenchmark(main, {
n: [1e6]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.posix;
- const input = String(conf.path);
-
+function main({ n, path }) {
bench.start();
for (var i = 0; i < n; i++) {
- p.isAbsolute(input);
+ posix.isAbsolute(path);
}
bench.end(n);
}
diff --git a/benchmark/path/isAbsolute-win32.js b/benchmark/path/isAbsolute-win32.js
index 3c93b24220..350e99d48b 100644
--- a/benchmark/path/isAbsolute-win32.js
+++ b/benchmark/path/isAbsolute-win32.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { win32 } = require('path');
const bench = common.createBenchmark(main, {
path: [
@@ -14,14 +14,10 @@ const bench = common.createBenchmark(main, {
n: [1e6]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.win32;
- const input = String(conf.path);
-
+function main({ n, path }) {
bench.start();
for (var i = 0; i < n; i++) {
- p.isAbsolute(input);
+ win32.isAbsolute(path);
}
bench.end(n);
}
diff --git a/benchmark/path/join-posix.js b/benchmark/path/join-posix.js
index 02b348cdff..f06f74ad37 100644
--- a/benchmark/path/join-posix.js
+++ b/benchmark/path/join-posix.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { posix } = require('path');
const bench = common.createBenchmark(main, {
paths: [
@@ -9,14 +9,12 @@ const bench = common.createBenchmark(main, {
n: [1e6]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.posix;
- const args = String(conf.paths).split('|');
+function main({ n, paths }) {
+ const args = paths.split('|');
bench.start();
for (var i = 0; i < n; i++) {
- p.join.apply(null, args);
+ posix.join.apply(null, args);
}
bench.end(n);
}
diff --git a/benchmark/path/join-win32.js b/benchmark/path/join-win32.js
index 96e4aeaa0c..2fa29f8ebf 100644
--- a/benchmark/path/join-win32.js
+++ b/benchmark/path/join-win32.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { win32 } = require('path');
const bench = common.createBenchmark(main, {
paths: [
@@ -9,14 +9,12 @@ const bench = common.createBenchmark(main, {
n: [1e6]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.win32;
- const args = String(conf.paths).split('|');
+function main({ n, paths }) {
+ const args = paths.split('|');
bench.start();
for (var i = 0; i < n; i++) {
- p.join.apply(null, args);
+ win32.join.apply(null, args);
}
bench.end(n);
}
diff --git a/benchmark/path/makeLong-win32.js b/benchmark/path/makeLong-win32.js
index 0c1ba38aed..4314692eef 100644
--- a/benchmark/path/makeLong-win32.js
+++ b/benchmark/path/makeLong-win32.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { win32 } = require('path');
const bench = common.createBenchmark(main, {
path: [
@@ -12,14 +12,10 @@ const bench = common.createBenchmark(main, {
n: [1e6]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.win32;
- const input = String(conf.path);
-
+function main({ n, path }) {
bench.start();
for (var i = 0; i < n; i++) {
- p._makeLong(input);
+ win32._makeLong(path);
}
bench.end(n);
}
diff --git a/benchmark/path/normalize-posix.js b/benchmark/path/normalize-posix.js
index 454a5ba9ae..84ac8d2c7c 100644
--- a/benchmark/path/normalize-posix.js
+++ b/benchmark/path/normalize-posix.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { posix } = require('path');
const bench = common.createBenchmark(main, {
path: [
@@ -14,14 +14,10 @@ const bench = common.createBenchmark(main, {
n: [1e6]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.posix;
- const input = String(conf.path);
-
+function main({ n, path }) {
bench.start();
for (var i = 0; i < n; i++) {
- p.normalize(input);
+ posix.normalize(path);
}
bench.end(n);
}
diff --git a/benchmark/path/normalize-win32.js b/benchmark/path/normalize-win32.js
index 480856228a..9b983eb968 100644
--- a/benchmark/path/normalize-win32.js
+++ b/benchmark/path/normalize-win32.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { win32 } = require('path');
const bench = common.createBenchmark(main, {
path: [
@@ -14,14 +14,10 @@ const bench = common.createBenchmark(main, {
n: [1e6]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.win32;
- const input = String(conf.path);
-
+function main({ n, path }) {
bench.start();
for (var i = 0; i < n; i++) {
- p.normalize(input);
+ win32.normalize(path);
}
bench.end(n);
}
diff --git a/benchmark/path/parse-posix.js b/benchmark/path/parse-posix.js
index 4f1fb898b8..dd1153d3c6 100644
--- a/benchmark/path/parse-posix.js
+++ b/benchmark/path/parse-posix.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { posix } = require('path');
const bench = common.createBenchmark(main, {
path: [
@@ -15,17 +15,13 @@ const bench = common.createBenchmark(main, {
n: [1e6]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.posix;
- const input = String(conf.path);
-
+function main({ n, path }) {
for (var i = 0; i < n; i++) {
- p.parse(input);
+ posix.parse(path);
}
bench.start();
for (i = 0; i < n; i++) {
- p.parse(input);
+ posix.parse(path);
}
bench.end(n);
}
diff --git a/benchmark/path/parse-win32.js b/benchmark/path/parse-win32.js
index da48f78dd5..8c4f06272f 100644
--- a/benchmark/path/parse-win32.js
+++ b/benchmark/path/parse-win32.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { win32 } = require('path');
const bench = common.createBenchmark(main, {
path: [
@@ -16,17 +16,13 @@ const bench = common.createBenchmark(main, {
n: [1e6]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.win32;
- const input = String(conf.path);
-
+function main({ n, path }) {
for (var i = 0; i < n; i++) {
- p.parse(input);
+ win32.parse(path);
}
bench.start();
for (i = 0; i < n; i++) {
- p.parse(input);
+ win32.parse(path);
}
bench.end(n);
}
diff --git a/benchmark/path/relative-posix.js b/benchmark/path/relative-posix.js
index 1280b686bc..70a0e434d9 100644
--- a/benchmark/path/relative-posix.js
+++ b/benchmark/path/relative-posix.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { posix } = require('path');
const bench = common.createBenchmark(main, {
paths: [
@@ -15,23 +15,20 @@ const bench = common.createBenchmark(main, {
n: [1e6]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.posix;
- var from = String(conf.paths);
+function main({ n, paths }) {
var to = '';
- const delimIdx = from.indexOf('|');
+ const delimIdx = paths.indexOf('|');
if (delimIdx > -1) {
- to = from.slice(delimIdx + 1);
- from = from.slice(0, delimIdx);
+ to = paths.slice(delimIdx + 1);
+ paths = paths.slice(0, delimIdx);
}
for (var i = 0; i < n; i++) {
- p.relative(from, to);
+ posix.relative(paths, to);
}
bench.start();
for (i = 0; i < n; i++) {
- p.relative(from, to);
+ posix.relative(paths, to);
}
bench.end(n);
}
diff --git a/benchmark/path/relative-win32.js b/benchmark/path/relative-win32.js
index f109cd9d96..4a97e82e02 100644
--- a/benchmark/path/relative-win32.js
+++ b/benchmark/path/relative-win32.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { win32 } = require('path');
const bench = common.createBenchmark(main, {
paths: [
@@ -13,25 +13,22 @@ const bench = common.createBenchmark(main, {
n: [1e6]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.win32;
- var from = String(conf.paths);
+function main({ n, paths }) {
var to = '';
- const delimIdx = from.indexOf('|');
+ const delimIdx = paths.indexOf('|');
if (delimIdx > -1) {
- to = from.slice(delimIdx + 1);
- from = from.slice(0, delimIdx);
+ to = paths.slice(delimIdx + 1);
+ paths = paths.slice(0, delimIdx);
}
// Warmup
for (var i = 0; i < n; i++) {
- p.relative(from, to);
+ win32.relative(paths, to);
}
bench.start();
for (i = 0; i < n; i++) {
- p.relative(from, to);
+ win32.relative(paths, to);
}
bench.end(n);
}
diff --git a/benchmark/path/resolve-posix.js b/benchmark/path/resolve-posix.js
index 4ef0d46e28..91f4c1da10 100644
--- a/benchmark/path/resolve-posix.js
+++ b/benchmark/path/resolve-posix.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { posix } = require('path');
const bench = common.createBenchmark(main, {
paths: [
@@ -12,14 +12,12 @@ const bench = common.createBenchmark(main, {
n: [1e6]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.posix;
- const args = String(conf.paths).split('|');
+function main({ n, paths }) {
+ const args = paths.split('|');
bench.start();
for (var i = 0; i < n; i++) {
- p.resolve.apply(null, args);
+ posix.resolve.apply(null, args);
}
bench.end(n);
}
diff --git a/benchmark/path/resolve-win32.js b/benchmark/path/resolve-win32.js
index c7d8b4cbb7..1047da5184 100644
--- a/benchmark/path/resolve-win32.js
+++ b/benchmark/path/resolve-win32.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common.js');
-const path = require('path');
+const { win32 } = require('path');
const bench = common.createBenchmark(main, {
paths: [
@@ -12,14 +12,12 @@ const bench = common.createBenchmark(main, {
n: [1e6]
});
-function main(conf) {
- const n = +conf.n;
- const p = path.win32;
- const args = String(conf.paths).split('|');
+function main({ n, paths }) {
+ const args = paths.split('|');
bench.start();
for (var i = 0; i < n; i++) {
- p.resolve.apply(null, args);
+ win32.resolve.apply(null, args);
}
bench.end(n);
}