2017-06-28 20:34:19 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common.js');
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
const bench = common.createBenchmark(main, {
|
2025-03-08 18:01:04 +01:00
|
|
|
n: [50, 2e2],
|
2024-10-11 15:26:42 -03:00
|
|
|
size: [1e2, 1e4],
|
|
|
|
method: ['deepEqual', 'notDeepEqual', 'deepStrictEqual', 'notDeepStrictEqual'],
|
2023-02-09 22:07:11 +01:00
|
|
|
}, {
|
|
|
|
combinationFilter: (p) => {
|
2025-03-08 18:01:04 +01:00
|
|
|
return p.size === 1e4 && p.n === 50 ||
|
2023-02-09 22:07:11 +01:00
|
|
|
p.size === 1e3 && p.n === 2e2 ||
|
2023-02-09 22:12:25 +01:00
|
|
|
p.size === 1e2 && p.n === 2e3 ||
|
|
|
|
p.size === 1;
|
2023-02-09 22:07:11 +01:00
|
|
|
},
|
2017-06-28 20:34:19 +02:00
|
|
|
});
|
|
|
|
|
2023-02-09 22:07:11 +01:00
|
|
|
function createObj(size, add = '') {
|
|
|
|
return Array.from({ length: size }, (n) => ({
|
2017-06-28 20:34:19 +02:00
|
|
|
foo: 'yarp',
|
|
|
|
nope: {
|
|
|
|
bar: `123${add}`,
|
|
|
|
a: [1, 2, 3],
|
2018-08-03 15:30:22 +02:00
|
|
|
baz: n,
|
|
|
|
c: {},
|
2019-01-31 21:05:17 -08:00
|
|
|
b: [],
|
|
|
|
},
|
2017-06-28 20:34:19 +02:00
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
2024-10-11 15:26:42 -03:00
|
|
|
function main({ size, n, method }) {
|
2018-05-30 03:41:57 +00:00
|
|
|
const fn = assert[method];
|
2023-02-09 22:07:11 +01:00
|
|
|
|
|
|
|
const actual = createObj(size);
|
|
|
|
const expected = method.includes('not') ? createObj(size, '4') : createObj(size);
|
2018-01-23 13:17:21 +01:00
|
|
|
|
|
|
|
bench.start();
|
2023-02-09 22:07:11 +01:00
|
|
|
for (let i = 0; i < n; ++i) {
|
|
|
|
fn(actual, expected);
|
2017-06-28 20:34:19 +02:00
|
|
|
}
|
2023-02-09 22:07:11 +01:00
|
|
|
bench.end(n);
|
2017-06-28 20:34:19 +02:00
|
|
|
}
|