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

Function main

benchmark/assert/deepequal-map.js:33–80  ·  view source on GitHub ↗
({ n, len, method, strict })

Source from the content-addressed store, hash-verified

31}
32
33function main({ n, len, method, strict }) {
34 const array = Array.from({ length: len }, () => '');
35
36 switch (method) {
37 case 'deepEqual_primitiveOnly': {
38 const values = array.map((_, i) => [`str_${i}`, 123]);
39 benchmark(strict ? deepStrictEqual : deepEqual, n, values);
40 break;
41 }
42 case 'deepEqual_objectOnly': {
43 const values = array.map((_, i) => [[`str_${i}`, 1], 123]);
44 benchmark(strict ? deepStrictEqual : deepEqual, n, values);
45 break;
46 }
47 case 'deepEqual_mixed': {
48 const values = array.map(
49 (_, i) => [i % 2 ? [`str_${i}`, 1] : `str_${i}`, 123],
50 );
51 benchmark(strict ? deepStrictEqual : deepEqual, n, values);
52 break;
53 }
54 case 'notDeepEqual_primitiveOnly': {
55 const values = array.map((_, i) => [`str_${i}`, 123]);
56 const values2 = values.slice(0);
57 values2[Math.floor(len / 2)] = ['w00t', 123];
58 benchmark(strict ? notDeepStrictEqual : notDeepEqual, n, values, values2);
59 break;
60 }
61 case 'notDeepEqual_objectOnly': {
62 const values = array.map((_, i) => [[`str_${i}`, 1], 123]);
63 const values2 = values.slice(0);
64 values2[Math.floor(len / 2)] = [['w00t'], 123];
65 benchmark(strict ? notDeepStrictEqual : notDeepEqual, n, values, values2);
66 break;
67 }
68 case 'notDeepEqual_mixed': {
69 const values = array.map(
70 (_, i) => [i % 2 ? [`str_${i}`, 1] : `str_${i}`, 123],
71 );
72 const values2 = values.slice(0);
73 values2[0] = ['w00t', 123];
74 benchmark(strict ? notDeepStrictEqual : notDeepEqual, n, values, values2);
75 break;
76 }
77 default:
78 throw new Error(`Unsupported method ${method}`);
79 }
80}

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…