Commit 2baf04d
committed
⚡ Faster
Calling `SequenceSet#normalize` on a frozen set can be more than 4x
faster, by simply re-parsing `@string` and scanning its elements, rather
than fully generating a new string and comparing it with `@string`.
```
normal
reparse and check: 20449.2 i/s
generate and compare: 20267.2 i/s - 1.01x slower
v0.5.12: 3090.2 i/s - 6.62x slower
frozen and normal
generate and compare: 19328485.2 i/s
reparse and check: 17455122.3 i/s - 1.11x slower
v0.5.12: 3730.0 i/s - 5181.95x slower
unsorted
reparse and check: 16936.2 i/s
generate and compare: 16872.9 i/s - 1.00x slower
v0.5.12: 2583.6 i/s - 6.56x slower
abnormal
generate and compare: 17610.8 i/s
reparse and check: 16596.1 i/s - 1.06x slower
v0.5.12: 2560.3 i/s - 6.88x slower
frozen unsorted
reparse and check: 10089.5 i/s
v0.5.12: 2333.7 i/s - 4.32x slower
generate and compare: 2093.1 i/s - 4.82x slower
frozen abnormal
reparse and check: 10392.1 i/s
v0.5.12: 2354.5 i/s - 4.41x slower
generate and compare: 2124.3 i/s - 4.89x slower
```
Please note that these results do vary based on benchmark settings, e.g:
size of the sequence set.SequenceSet#normalize when frozen1 parent 74156fd commit 2baf04d
File tree
2 files changed
+31
-3
lines changed- benchmarks
- lib/net/imap
2 files changed
+31
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
54 | 58 | | |
55 | 59 | | |
56 | 60 | | |
| |||
68 | 72 | | |
69 | 73 | | |
70 | 74 | | |
71 | | - | |
| 75 | + | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
75 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
76 | 84 | | |
77 | 85 | | |
78 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
79 | 99 | | |
80 | 100 | | |
81 | 101 | | |
| |||
96 | 116 | | |
97 | 117 | | |
98 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
99 | 125 | | |
100 | 126 | | |
101 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1707 | 1707 | | |
1708 | 1708 | | |
1709 | 1709 | | |
1710 | | - | |
| 1710 | + | |
1711 | 1711 | | |
1712 | 1712 | | |
1713 | 1713 | | |
| |||
1907 | 1907 | | |
1908 | 1908 | | |
1909 | 1909 | | |
| 1910 | + | |
| 1911 | + | |
1910 | 1912 | | |
1911 | 1913 | | |
1912 | 1914 | | |
| |||
0 commit comments