Commit 717c5ac
committed
assert,util: improve (partial) deep equal comparison performance
The circular check is now done lazily. That way only users that
actually make use of such structures have to do the calculation
overhead. It is an initial overhead the very first time it's run
to detect the circular structure, while every following call uses
the check for circular structures by default. This improves the
performance for object comparison significantly.
On top of that, this includes an optimised algorithm for sets and
maps that contain objects as keys. The tracking is now done in an
array and the array size is not changed when elements at the start
or at the end of the array is detected. The order of the elements
matter, so a reversed key order is now a magnitude faster. Insert
sort comparison is also signficantly faster, random order is a tad
faster.1 parent e102f40 commit 717c5ac
File tree
3 files changed
+255
-136
lines changed- benchmark/assert
- lib/internal/util
3 files changed
+255
-136
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
19 | 24 | | |
20 | 25 | | |
21 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
22 | 36 | | |
23 | 37 | | |
24 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
25 | 44 | | |
26 | 45 | | |
27 | 46 | | |
| |||
30 | 49 | | |
31 | 50 | | |
32 | 51 | | |
33 | | - | |
34 | | - | |
| 52 | + | |
| 53 | + | |
35 | 54 | | |
36 | 55 | | |
37 | 56 | | |
38 | 57 | | |
39 | | - | |
| 58 | + | |
40 | 59 | | |
41 | 60 | | |
42 | 61 | | |
43 | 62 | | |
44 | | - | |
| 63 | + | |
45 | 64 | | |
46 | 65 | | |
47 | 66 | | |
48 | 67 | | |
49 | 68 | | |
50 | 69 | | |
51 | | - | |
| 70 | + | |
52 | 71 | | |
53 | 72 | | |
54 | 73 | | |
55 | 74 | | |
56 | 75 | | |
57 | 76 | | |
58 | | - | |
| 77 | + | |
59 | 78 | | |
60 | 79 | | |
61 | 80 | | |
62 | 81 | | |
63 | 82 | | |
64 | 83 | | |
65 | | - | |
| 84 | + | |
66 | 85 | | |
67 | 86 | | |
68 | 87 | | |
| |||
71 | 90 | | |
72 | 91 | | |
73 | 92 | | |
74 | | - | |
| 93 | + | |
75 | 94 | | |
76 | 95 | | |
77 | 96 | | |
| |||
0 commit comments