diff options
author | Andreas Madsen <amwebdk@gmail.com> | 2016-02-08 21:50:10 +0100 |
---|---|---|
committer | Rod Vagg <rod@vagg.org> | 2016-02-26 20:29:10 +1100 |
commit | 15720fa25ad62e1ac497417aaa0e92cc260f9245 (patch) | |
tree | 55c0954d51d9b101e3c8046a4e9186a5536ac460 /benchmark/assert | |
parent | f6c505d0b1771d75bd23442e0049ad9581979901 (diff) | |
download | node-new-15720fa25ad62e1ac497417aaa0e92cc260f9245.tar.gz |
benchmark: fix configuation parameters
The benchmark runner spawns new processes for each configuration. The
specific configuration is transfered by process.argv. This means that
the values have to be parsed. As of right now only numbers and strings
are parsed correctly. However other values such as objects where used.
This fixes the benchmarks that used non-string/number values and
prevents future issues by asserting the type.
PR-URL: https://github.com/nodejs/node/pull/5177
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Diffstat (limited to 'benchmark/assert')
-rw-r--r-- | benchmark/assert/deepequal-prims-and-objs-big-array.js | 25 | ||||
-rw-r--r-- | benchmark/assert/deepequal-prims-and-objs-big-loop.js | 25 |
2 files changed, 28 insertions, 22 deletions
diff --git a/benchmark/assert/deepequal-prims-and-objs-big-array.js b/benchmark/assert/deepequal-prims-and-objs-big-array.js index d8d2b57331..dc18d959bb 100644 --- a/benchmark/assert/deepequal-prims-and-objs-big-array.js +++ b/benchmark/assert/deepequal-prims-and-objs-big-array.js @@ -1,22 +1,25 @@ 'use strict'; var common = require('../common.js'); var assert = require('assert'); + +const primValues = { + 'null': null, + 'undefined': undefined, + 'string': 'a', + 'number': 1, + 'boolean': true, + 'object': { 0: 'a' }, + 'array': [1, 2, 3], + 'new-array': new Array([1, 2, 3]) +}; + var bench = common.createBenchmark(main, { - prim: [ - null, - undefined, - 'a', - 1, - true, - {0: 'a'}, - [1, 2, 3], - new Array([1, 2, 3]) - ], + prim: Object.keys(primValues), n: [25] }); function main(conf) { - var prim = conf.prim; + var prim = primValues[conf.prim]; var n = +conf.n; var primArray; var primArrayCompare; diff --git a/benchmark/assert/deepequal-prims-and-objs-big-loop.js b/benchmark/assert/deepequal-prims-and-objs-big-loop.js index 5f0519bb3b..3c76a586f7 100644 --- a/benchmark/assert/deepequal-prims-and-objs-big-loop.js +++ b/benchmark/assert/deepequal-prims-and-objs-big-loop.js @@ -1,22 +1,25 @@ 'use strict'; var common = require('../common.js'); var assert = require('assert'); + +const primValues = { + 'null': null, + 'undefined': undefined, + 'string': 'a', + 'number': 1, + 'boolean': true, + 'object': { 0: 'a' }, + 'array': [1, 2, 3], + 'new-array': new Array([1, 2, 3]) +}; + var bench = common.createBenchmark(main, { - prim: [ - null, - undefined, - 'a', - 1, - true, - {0: 'a'}, - [1, 2, 3], - new Array([1, 2, 3]) - ], + prim: Object.keys(primValues), n: [1e5] }); function main(conf) { - var prim = conf.prim; + var prim = primValues[conf.prim]; var n = +conf.n; var x; |