Commit 6c869cc
committed
Add (*Set).FromJSON benchmarks and switch to post-accumulation sort.
Set deserialization with children in reverse order performs an insertion sort. Sets serialized by
structured-merge-diff are sorted, but in practice the serialization of sets is controlled by clients
and they can (intentionally or not) exercise this worst case. Switching to a bulk insert followed by
a sort appears to perform no worse in the best case (sorted) and is significantly better in the
worst case:
│ master.bench │ bulk.bench │
│ sec/op │ sec/op vs base │
SetFromJSON/children_in_ascending_order 1.338m ± 0% 1.316m ± 1% -1.60% (p=0.001 n=10)
SetFromJSON/children_in_descending_order 20.520m ± 1% 1.356m ± 1% -93.39% (p=0.000 n=10)
SetFromJSON/grandchildren_in_ascending_order 3.001m ± 1% 2.935m ± 1% -2.20% (p=0.000 n=10)
SetFromJSON/grandchildren_in_descending_order 39.963m ± 0% 2.923m ± 1% -92.69% (p=0.000 n=10)
geomean 7.575m 1.978m -73.88%
│ master.bench │ bulk.bench │
│ B/op │ B/op vs base │
SetFromJSON/children_in_ascending_order 1.320Mi ± 0% 1.320Mi ± 0% ~ (p=0.303 n=10)
SetFromJSON/children_in_descending_order 1.320Mi ± 0% 1.320Mi ± 0% +0.00% (p=0.000 n=10)
SetFromJSON/grandchildren_in_ascending_order 2.512Mi ± 0% 2.512Mi ± 0% +0.00% (p=0.001 n=10)
SetFromJSON/grandchildren_in_descending_order 2.908Mi ± 0% 2.512Mi ± 0% -13.61% (p=0.000 n=10)
geomean 1.889Mi 1.821Mi -3.59%
│ master.bench │ bulk.bench │
│ allocs/op │ allocs/op vs base │
SetFromJSON/children_in_ascending_order 25.99k ± 0% 25.99k ± 0% ~ (p=1.000 n=10) ¹
SetFromJSON/children_in_descending_order 25.99k ± 0% 25.99k ± 0% ~ (p=1.000 n=10) ¹
SetFromJSON/grandchildren_in_ascending_order 69.24k ± 0% 69.24k ± 0% ~ (p=1.000 n=10) ¹
SetFromJSON/grandchildren_in_descending_order 77.89k ± 0% 69.24k ± 0% -11.10% (p=0.000 n=10)
geomean 43.68k 42.42k -2.90%
¹ all samples are equal1 parent 3392408 commit 6c869cc
File tree
6 files changed
+42
-18
lines changed- fieldpath
- testdata
6 files changed
+42
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
204 | 205 | | |
205 | 206 | | |
206 | 207 | | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
| 208 | + | |
216 | 209 | | |
217 | 210 | | |
218 | 211 | | |
219 | 212 | | |
220 | 213 | | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
| 214 | + | |
230 | 215 | | |
231 | 216 | | |
232 | 217 | | |
233 | 218 | | |
234 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
235 | 227 | | |
236 | 228 | | |
237 | 229 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
330 | 331 | | |
331 | 332 | | |
332 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
0 commit comments