From 1000c785bd613475a93854ec09e9d110af923fbf Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 30 May 2018 03:38:35 +0000 Subject: [PATCH] benchmark: refactor deepequal-map MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a minor refactor of benchmark/assert/deepequal-map.js to reduce exceptions that need to be made for lint compliance. PR-URL: https://github.com/nodejs/node/pull/21030 Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat --- benchmark/assert/deepequal-map.js | 33 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/benchmark/assert/deepequal-map.js b/benchmark/assert/deepequal-map.js index bdd3c5c6b8c..c6c7173fe8e 100644 --- a/benchmark/assert/deepequal-map.js +++ b/benchmark/assert/deepequal-map.js @@ -1,9 +1,8 @@ 'use strict'; -/* eslint-disable no-restricted-properties */ - const common = require('../common.js'); -const assert = require('assert'); +const { deepEqual, deepStrictEqual, notDeepEqual, notDeepStrictEqual } = + require('assert'); const bench = common.createBenchmark(main, { n: [5e2], @@ -47,74 +46,74 @@ function main({ n, len, method }) { // Empty string falls through to next line as default, mostly for tests. case 'deepEqual_primitiveOnly': values = array.map((_, i) => [`str_${i}`, 123]); - benchmark(assert.deepEqual, n, values); + benchmark(deepEqual, n, values); break; case 'deepStrictEqual_primitiveOnly': values = array.map((_, i) => [`str_${i}`, 123]); - benchmark(assert.deepStrictEqual, n, values); + benchmark(deepStrictEqual, n, values); break; case 'deepEqual_objectOnly': values = array.map((_, i) => [[`str_${i}`, 1], 123]); - benchmark(assert.deepEqual, n, values); + benchmark(deepEqual, n, values); break; case 'deepStrictEqual_objectOnly': values = array.map((_, i) => [[`str_${i}`, 1], 123]); - benchmark(assert.deepStrictEqual, n, values); + benchmark(deepStrictEqual, n, values); break; case 'deepEqual_mixed': values = array.map((_, i) => [i % 2 ? [`str_${i}`, 1] : `str_${i}`, 123]); - benchmark(assert.deepEqual, n, values); + benchmark(deepEqual, n, values); break; case 'deepStrictEqual_mixed': values = array.map((_, i) => [i % 2 ? [`str_${i}`, 1] : `str_${i}`, 123]); - benchmark(assert.deepStrictEqual, n, values); + benchmark(deepStrictEqual, n, values); break; case 'deepEqual_looseMatches': values = array.map((_, i) => [i, i]); values2 = values.slice().map((v) => [String(v[0]), String(v[1])]); - benchmark(assert.deepEqual, n, values, values2); + benchmark(deepEqual, n, values, values2); break; case 'notDeepEqual_primitiveOnly': values = array.map((_, i) => [`str_${i}`, 123]); values2 = values.slice(0); values2[Math.floor(len / 2)] = ['w00t', 123]; - benchmark(assert.notDeepEqual, n, values, values2); + benchmark(notDeepEqual, n, values, values2); break; case 'notDeepStrictEqual_primitiveOnly': values = array.map((_, i) => [`str_${i}`, 123]); values2 = values.slice(0); values2[Math.floor(len / 2)] = ['w00t', 123]; - benchmark(assert.notDeepStrictEqual, n, values, values2); + benchmark(notDeepStrictEqual, n, values, values2); break; case 'notDeepEqual_objectOnly': values = array.map((_, i) => [[`str_${i}`, 1], 123]); values2 = values.slice(0); values2[Math.floor(len / 2)] = [['w00t'], 123]; - benchmark(assert.notDeepEqual, n, values, values2); + benchmark(notDeepEqual, n, values, values2); break; case 'notDeepStrictEqual_objectOnly': values = array.map((_, i) => [[`str_${i}`, 1], 123]); values2 = values.slice(0); values2[Math.floor(len / 2)] = [['w00t'], 123]; - benchmark(assert.notDeepStrictEqual, n, values, values2); + benchmark(notDeepStrictEqual, n, values, values2); break; case 'notDeepEqual_mixed': values = array.map((_, i) => [i % 2 ? [`str_${i}`, 1] : `str_${i}`, 123]); values2 = values.slice(0); values2[0] = ['w00t', 123]; - benchmark(assert.notDeepEqual, n, values, values2); + benchmark(notDeepEqual, n, values, values2); break; case 'notDeepStrictEqual_mixed': values = array.map((_, i) => [i % 2 ? [`str_${i}`, 1] : `str_${i}`, 123]); values2 = values.slice(0); values2[0] = ['w00t', 123]; - benchmark(assert.notDeepStrictEqual, n, values, values2); + benchmark(notDeepStrictEqual, n, values, values2); break; case 'notDeepEqual_looseMatches': values = array.map((_, i) => [i, i]); values2 = values.slice().map((v) => [String(v[0]), String(v[1])]); values2[len - 1] = [String(len + 1), String(len + 1)]; - benchmark(assert.notDeepEqual, n, values, values2); + benchmark(notDeepEqual, n, values, values2); break; default: throw new Error(`Unsupported method ${method}`);