1'use strict'; 2 3const common = require('../common.js'); 4const assert = require('assert'); 5 6const bench = common.createBenchmark(main, { 7 n: [5e3], 8 size: [1e2, 1e3, 5e4], 9 strict: [0, 1], 10 method: ['deepEqual', 'notDeepEqual'], 11}); 12 13function createObj(source, add = '') { 14 return source.map((n) => ({ 15 foo: 'yarp', 16 nope: { 17 bar: `123${add}`, 18 a: [1, 2, 3], 19 baz: n, 20 c: {}, 21 b: [], 22 }, 23 })); 24} 25 26function main({ size, n, method, strict }) { 27 // TODO: Fix this "hack". `n` should not be manipulated. 28 n = Math.min(Math.ceil(n / size), 20); 29 30 const source = Array.apply(null, Array(size)); 31 const actual = createObj(source); 32 const expected = createObj(source); 33 const expectedWrong = createObj(source, '4'); 34 35 if (strict) { 36 method = method.replace('eep', 'eepStrict'); 37 } 38 const fn = assert[method]; 39 const value2 = method.includes('not') ? expectedWrong : expected; 40 41 bench.start(); 42 for (let i = 0; i < n; ++i) { 43 fn(actual, value2); 44 } 45 bench.end(n); 46} 47