diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2018-08-03 15:30:22 +0200 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-08-13 11:46:40 +0200 |
commit | 5442c28b651a79c2269bf2b931e81cd553171656 (patch) | |
tree | 18717ad51469a3b9650bca96bdb36433cfc9345c /benchmark/assert/deepequal-object.js | |
parent | c29aff3ac7071a2d66206a3767fd946691c36c7f (diff) | |
download | android-node-v8-5442c28b651a79c2269bf2b931e81cd553171656.tar.gz android-node-v8-5442c28b651a79c2269bf2b931e81cd553171656.tar.bz2 android-node-v8-5442c28b651a79c2269bf2b931e81cd553171656.zip |
benchmark: improve assert benchmarks
This reduces the runtime and makes sure the strict and loose options
can be tested individually.
Besides that a couple of redundant cases were removed.
PR-URL: https://github.com/nodejs/node/pull/22211
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'benchmark/assert/deepequal-object.js')
-rw-r--r-- | benchmark/assert/deepequal-object.js | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/benchmark/assert/deepequal-object.js b/benchmark/assert/deepequal-object.js index 124943b19e..1a9c826a00 100644 --- a/benchmark/assert/deepequal-object.js +++ b/benchmark/assert/deepequal-object.js @@ -4,13 +4,12 @@ const common = require('../common.js'); const assert = require('assert'); const bench = common.createBenchmark(main, { - n: [1e6], - size: [1e2, 1e3, 1e4], + n: [5e3], + size: [1e2, 1e3, 5e4], + strict: [0, 1], method: [ 'deepEqual', - 'deepStrictEqual', - 'notDeepEqual', - 'notDeepStrictEqual' + 'notDeepEqual' ] }); @@ -20,14 +19,16 @@ function createObj(source, add = '') { nope: { bar: `123${add}`, a: [1, 2, 3], - baz: n + baz: n, + c: {}, + b: [] } })); } -function main({ size, n, method }) { +function main({ size, n, method, strict }) { // TODO: Fix this "hack". `n` should not be manipulated. - n = n / size; + n = Math.min(Math.ceil(n / size), 20); if (!method) method = 'deepEqual'; @@ -37,6 +38,9 @@ function main({ size, n, method }) { const expected = createObj(source); const expectedWrong = createObj(source, '4'); + if (strict) { + method = method.replace('eep', 'eepStrict'); + } const fn = assert[method]; const value2 = method.includes('not') ? expectedWrong : expected; |