summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2017-12-30 03:57:38 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2018-01-23 01:29:27 +0100
commitfd45187d345c8c11533da52b0c8c8b658dd40d80 (patch)
tree106a4da65424fe23a5fd636e30990e30efa631a6 /benchmark
parent50d2554dd183d6fc58d55b2c7c0aa1a086c8253b (diff)
downloadandroid-node-v8-fd45187d345c8c11533da52b0c8c8b658dd40d80.tar.gz
android-node-v8-fd45187d345c8c11533da52b0c8c8b658dd40d80.tar.bz2
android-node-v8-fd45187d345c8c11533da52b0c8c8b658dd40d80.zip
benchmark: (misc) 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')
-rw-r--r--benchmark/misc/freelist.js3
-rw-r--r--benchmark/misc/function_call/index.js8
-rw-r--r--benchmark/misc/object-property-bench.js6
-rw-r--r--benchmark/misc/punycode.js6
-rw-r--r--benchmark/misc/startup.js3
-rw-r--r--benchmark/misc/util-extend-vs-object-assign.js10
6 files changed, 15 insertions, 21 deletions
diff --git a/benchmark/misc/freelist.js b/benchmark/misc/freelist.js
index 461f4b3e4c..0530255728 100644
--- a/benchmark/misc/freelist.js
+++ b/benchmark/misc/freelist.js
@@ -8,9 +8,8 @@ const bench = common.createBenchmark(main, {
flags: ['--expose-internals']
});
-function main(conf) {
+function main({ n }) {
const FreeList = require('internal/freelist');
- const n = conf.n;
const poolSize = 1000;
const list = new FreeList('test', poolSize, Object);
var i;
diff --git a/benchmark/misc/function_call/index.js b/benchmark/misc/function_call/index.js
index 6a2595d2ae..91efa57359 100644
--- a/benchmark/misc/function_call/index.js
+++ b/benchmark/misc/function_call/index.js
@@ -31,13 +31,13 @@ const bench = common.createBenchmark(main, {
millions: [1, 10, 50]
});
-function main(conf) {
- const n = +conf.millions * 1e6;
+function main({ millions, type }) {
+ const n = millions * 1e6;
- const fn = conf.type === 'cxx' ? cxx : js;
+ const fn = type === 'cxx' ? cxx : js;
bench.start();
for (var i = 0; i < n; i++) {
fn();
}
- bench.end(+conf.millions);
+ bench.end(millions);
}
diff --git a/benchmark/misc/object-property-bench.js b/benchmark/misc/object-property-bench.js
index d6afd4e9c0..37da82d887 100644
--- a/benchmark/misc/object-property-bench.js
+++ b/benchmark/misc/object-property-bench.js
@@ -59,10 +59,10 @@ function runSymbol(n) {
bench.end(n / 1e6);
}
-function main(conf) {
- const n = +conf.millions * 1e6;
+function main({ millions, method }) {
+ const n = millions * 1e6;
- switch (conf.method) {
+ switch (method) {
// '' is a default case for tests
case '':
case 'property':
diff --git a/benchmark/misc/punycode.js b/benchmark/misc/punycode.js
index 40bcd70302..7016fa1171 100644
--- a/benchmark/misc/punycode.js
+++ b/benchmark/misc/punycode.js
@@ -62,10 +62,8 @@ function runICU(n, val) {
bench.end(n);
}
-function main(conf) {
- const n = +conf.n;
- const val = conf.val;
- switch (conf.method) {
+function main({ n, val, method }) {
+ switch (method) {
// '' is a default case for tests
case '':
case 'punycode':
diff --git a/benchmark/misc/startup.js b/benchmark/misc/startup.js
index b010f9fa46..703146f081 100644
--- a/benchmark/misc/startup.js
+++ b/benchmark/misc/startup.js
@@ -8,8 +8,7 @@ const bench = common.createBenchmark(startNode, {
dur: [1]
});
-function startNode(conf) {
- const dur = +conf.dur;
+function startNode({ dur }) {
var go = true;
var starts = 0;
diff --git a/benchmark/misc/util-extend-vs-object-assign.js b/benchmark/misc/util-extend-vs-object-assign.js
index f2a039bc5d..149619f6e1 100644
--- a/benchmark/misc/util-extend-vs-object-assign.js
+++ b/benchmark/misc/util-extend-vs-object-assign.js
@@ -8,19 +8,17 @@ const bench = common.createBenchmark(main, {
n: [10e4]
});
-function main(conf) {
+function main({ n, type }) {
let fn;
- const n = conf.n | 0;
-
- if (conf.type === 'extend') {
+ if (type === 'extend') {
fn = util._extend;
- } else if (conf.type === 'assign') {
+ } else if (type === 'assign') {
fn = Object.assign;
}
// Force-optimize the method to test so that the benchmark doesn't
// get disrupted by the optimizer kicking in halfway through.
- for (var i = 0; i < conf.type.length * 10; i += 1)
+ for (var i = 0; i < type.length * 10; i += 1)
fn({}, process.env);
const obj = new Proxy({}, { set: function(a, b, c) { return true; } });