diff options
Diffstat (limited to 'benchmark')
-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 | ||||
-rw-r--r-- | benchmark/buffers/buffer-read.js | 2 | ||||
-rw-r--r-- | benchmark/buffers/buffer-tostring.js | 4 | ||||
-rw-r--r-- | benchmark/buffers/buffer-write.js | 2 | ||||
-rw-r--r-- | benchmark/common.js | 4 |
6 files changed, 36 insertions, 26 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; diff --git a/benchmark/buffers/buffer-read.js b/benchmark/buffers/buffer-read.js index e50de84b04..47affeee79 100644 --- a/benchmark/buffers/buffer-read.js +++ b/benchmark/buffers/buffer-read.js @@ -2,7 +2,7 @@ var common = require('../common.js'); var bench = common.createBenchmark(main, { - noAssert: [false, true], + noAssert: ['false', 'true'], buffer: ['fast', 'slow'], type: ['UInt8', 'UInt16LE', 'UInt16BE', 'UInt32LE', 'UInt32BE', diff --git a/benchmark/buffers/buffer-tostring.js b/benchmark/buffers/buffer-tostring.js index 948052042d..97f5fb1229 100644 --- a/benchmark/buffers/buffer-tostring.js +++ b/benchmark/buffers/buffer-tostring.js @@ -3,13 +3,13 @@ const common = require('../common.js'); const bench = common.createBenchmark(main, { - arg: [true, false], + arg: ['true', 'false'], len: [0, 1, 64, 1024], n: [1e7] }); function main(conf) { - const arg = conf.arg; + const arg = conf.arg === 'true'; const len = conf.len | 0; const n = conf.n | 0; const buf = Buffer(len).fill(42); diff --git a/benchmark/buffers/buffer-write.js b/benchmark/buffers/buffer-write.js index 22383319d9..657cebfacb 100644 --- a/benchmark/buffers/buffer-write.js +++ b/benchmark/buffers/buffer-write.js @@ -1,7 +1,7 @@ 'use strict'; var common = require('../common.js'); var bench = common.createBenchmark(main, { - noAssert: [false, true], + noAssert: ['false', 'true'], buffer: ['fast', 'slow'], type: ['UInt8', 'UInt16LE', 'UInt16BE', 'UInt32LE', 'UInt32BE', diff --git a/benchmark/common.js b/benchmark/common.js index 6878d41d14..1ff4b50f8a 100644 --- a/benchmark/common.js +++ b/benchmark/common.js @@ -154,6 +154,10 @@ Benchmark.prototype._run = function() { var j = 0; set.forEach(function(s) { vals.forEach(function(val) { + if (typeof val !== 'number' && typeof val !== 'string') { + throw new TypeError(`configuration "${key}" had type ${typeof val}`); + } + newSet[j++] = s.concat(key + '=' + val); }); }); |