MCPcopy Index your code
hub / github.com/nodejs/node / main

Function main

benchmark/assert/deepequal-set.js:52–99  ·  view source on GitHub ↗
({ n, len, method, strict, order })

Source from the content-addressed store, hash-verified

50}
51
52function main({ n, len, method, strict, order }) {
53 const array = Array.from({ length: len }, () => '');
54
55 switch (method) {
56 case 'deepEqual_primitiveOnly': {
57 const values = array.map((_, i) => `str_${i}`);
58 benchmark(strict ? deepStrictEqual : deepEqual, n, values, values, order);
59 break;
60 }
61 case 'deepEqual_objectOnly': {
62 const values = array.map((_, i) => [`str_${i}`, null]);
63 benchmark(strict ? deepStrictEqual : deepEqual, n, values, values, order);
64 break;
65 }
66 case 'deepEqual_mixed': {
67 const values = array.map((_, i) => {
68 return i % 2 ? [`str_${i}`, null] : `str_${i}`;
69 });
70 benchmark(strict ? deepStrictEqual : deepEqual, n, values, values, order);
71 break;
72 }
73 case 'notDeepEqual_primitiveOnly': {
74 const values = array.map((_, i) => `str_${i}`);
75 const values2 = values.slice(0);
76 values2[Math.floor(len / 2)] = 'w00t';
77 benchmark(strict ? notDeepStrictEqual : notDeepEqual, n, values, values2, order);
78 break;
79 }
80 case 'notDeepEqual_objectOnly': {
81 const values = array.map((_, i) => [`str_${i}`, null]);
82 const values2 = values.slice(0);
83 values2[Math.floor(len / 2)] = ['w00t'];
84 benchmark(strict ? notDeepStrictEqual : notDeepEqual, n, values, values2, order);
85 break;
86 }
87 case 'notDeepEqual_mixed': {
88 const values = array.map((_, i) => {
89 return i % 2 ? [`str_${i}`, null] : `str_${i}`;
90 });
91 const values2 = values.slice();
92 values2[0] = 'w00t';
93 benchmark(strict ? notDeepStrictEqual : notDeepEqual, n, values, values2, order);
94 break;
95 }
96 default:
97 throw new Error(`Unsupported method "${method}"`);
98 }
99}

Callers

nothing calls this directly

Calls 4

benchmarkFunction · 0.70
mapMethod · 0.65
sliceMethod · 0.65
fromMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…