From ed91f58414d447e4ce20fe58fb5d6efdd16b68af Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sat, 30 Dec 2017 03:59:27 +0100 Subject: benchmark: (es) use destructuring PR-URL: https://github.com/nodejs/node/pull/18250 Reviewed-By: Matteo Collina Reviewed-By: James M Snell --- benchmark/es/defaultparams-bench.js | 6 +++--- benchmark/es/destructuring-bench.js | 6 +++--- benchmark/es/destructuring-object-bench.js | 6 +++--- benchmark/es/foreach-bench.js | 8 +++----- benchmark/es/map-bench.js | 6 +++--- benchmark/es/restparams-bench.js | 6 +++--- benchmark/es/spread-bench.js | 14 +++++++------- benchmark/es/string-concatenations.js | 6 ++---- benchmark/es/string-repeat.js | 8 +++----- 9 files changed, 30 insertions(+), 36 deletions(-) (limited to 'benchmark/es') diff --git a/benchmark/es/defaultparams-bench.js b/benchmark/es/defaultparams-bench.js index 1393abbe54..ce2132718c 100644 --- a/benchmark/es/defaultparams-bench.js +++ b/benchmark/es/defaultparams-bench.js @@ -38,10 +38,10 @@ function runDefaultParams(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) { case '': // Empty string falls through to next line as default, mostly for tests. case 'withoutdefaults': diff --git a/benchmark/es/destructuring-bench.js b/benchmark/es/destructuring-bench.js index a6c9a81ae0..f244506860 100644 --- a/benchmark/es/destructuring-bench.js +++ b/benchmark/es/destructuring-bench.js @@ -34,10 +34,10 @@ function runSwapDestructured(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) { case '': // Empty string falls through to next line as default, mostly for tests. case 'swap': diff --git a/benchmark/es/destructuring-object-bench.js b/benchmark/es/destructuring-object-bench.js index 63e085a242..73687f018d 100644 --- a/benchmark/es/destructuring-object-bench.js +++ b/benchmark/es/destructuring-object-bench.js @@ -33,10 +33,10 @@ function runDestructured(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) { case '': // Empty string falls through to next line as default, mostly for tests. case 'normal': diff --git a/benchmark/es/foreach-bench.js b/benchmark/es/foreach-bench.js index 62aa02236f..c7caa7cee6 100644 --- a/benchmark/es/foreach-bench.js +++ b/benchmark/es/foreach-bench.js @@ -52,17 +52,15 @@ function useForEach(n, items) { bench.end(n / 1e6); } -function main(conf) { - const n = +conf.millions * 1e6; - const count = +conf.count; - +function main({ millions, count, method }) { + const n = millions * 1e6; const items = new Array(count); var i; var fn; for (i = 0; i < count; i++) items[i] = i; - switch (conf.method) { + switch (method) { case '': // Empty string falls through to next line as default, mostly for tests. case 'for': diff --git a/benchmark/es/map-bench.js b/benchmark/es/map-bench.js index 035ed1a22a..ba8e35c2eb 100644 --- a/benchmark/es/map-bench.js +++ b/benchmark/es/map-bench.js @@ -108,10 +108,10 @@ function runMap(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) { case '': // Empty string falls through to next line as default, mostly for tests. case 'object': diff --git a/benchmark/es/restparams-bench.js b/benchmark/es/restparams-bench.js index 32fa985ded..78299d292c 100644 --- a/benchmark/es/restparams-bench.js +++ b/benchmark/es/restparams-bench.js @@ -60,10 +60,10 @@ function runUseArguments(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) { case '': // Empty string falls through to next line as default, mostly for tests. case 'copy': diff --git a/benchmark/es/spread-bench.js b/benchmark/es/spread-bench.js index b6dfb5963e..3c6cc93ea4 100644 --- a/benchmark/es/spread-bench.js +++ b/benchmark/es/spread-bench.js @@ -23,16 +23,16 @@ function makeTest(count, rest) { } } -function main(conf) { - const n = +conf.millions * 1e6; - const ctx = conf.context === 'context' ? {} : null; - var fn = makeTest(conf.count, conf.rest); - const args = new Array(conf.count); +function main({ millions, context, count, rest, method }) { + const n = millions * 1e6; + const ctx = context === 'context' ? {} : null; + var fn = makeTest(count, rest); + const args = new Array(count); var i; - for (i = 0; i < conf.count; i++) + for (i = 0; i < count; i++) args[i] = i; - switch (conf.method) { + switch (method) { case '': // Empty string falls through to next line as default, mostly for tests. case 'apply': diff --git a/benchmark/es/string-concatenations.js b/benchmark/es/string-concatenations.js index b7f5c31936..a40b7fa8c3 100644 --- a/benchmark/es/string-concatenations.js +++ b/benchmark/es/string-concatenations.js @@ -17,15 +17,13 @@ const configs = { const bench = common.createBenchmark(main, configs); -function main(conf) { - const n = +conf.n; - +function main({ n, mode }) { const str = 'abc'; const num = 123; let string; - switch (conf.mode) { + switch (mode) { case '': // Empty string falls through to next line as default, mostly for tests. case 'multi-concat': diff --git a/benchmark/es/string-repeat.js b/benchmark/es/string-repeat.js index 1ddc7db78c..e5bdbb5cc1 100644 --- a/benchmark/es/string-repeat.js +++ b/benchmark/es/string-repeat.js @@ -12,14 +12,12 @@ const configs = { const bench = common.createBenchmark(main, configs); -function main(conf) { - const n = +conf.n; - const size = +conf.size; - const character = conf.encoding === 'ascii' ? 'a' : '\ud83d\udc0e'; // '🐎' +function main({ n, size, encoding, mode }) { + const character = encoding === 'ascii' ? 'a' : '\ud83d\udc0e'; // '🐎' let str; - switch (conf.mode) { + switch (mode) { case '': // Empty string falls through to next line as default, mostly for tests. case 'Array': -- cgit v1.2.3