Commit 26509bc
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 │ bulk │
│ sec/op │ sec/op vs base │
SetFromJSON/children_in_ascending_order 1.286m ± 3% 1.341m ± 1% +4.27% (p=0.000 n=10)
SetFromJSON/children_in_descending_order 20.189m ± 0% 1.385m ± 1% -93.14% (p=0.000 n=10)
SetFromJSON/grandchildren_in_ascending_order 7.821m ± 1% 8.211m ± 1% +4.98% (p=0.000 n=10)
SetFromJSON/grandchildren_in_descending_order 75.16m ± 4% 13.31m ± 13% -82.28% (p=0.000 n=10)
geomean 11.11m 3.774m -66.04%
│ master │ bulk │
│ B/op │ B/op vs base │
SetFromJSON/children_in_ascending_order 1.320Mi ± 0% 1.320Mi ± 0% ~ (p=1.000 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 5.395Mi ± 0% 5.395Mi ± 0% +0.00% (p=0.000 n=10)
SetFromJSON/grandchildren_in_descending_order 6.187Mi ± 0% 5.395Mi ± 0% -12.80% (p=0.000 n=10)
geomean 2.761Mi 2.668Mi -3.37%
│ master │ bulk │
│ 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 138.4k ± 0% 138.4k ± 0% ~ (p=1.000 n=10) ¹
SetFromJSON/grandchildren_in_descending_order 155.7k ± 0% 138.4k ± 0% -11.11% (p=0.000 n=10)
geomean 61.77k 59.98k -2.90%
¹ all samples are equal1 parent 3392408 commit 26509bc
File tree
6 files changed
+82
-18
lines changed- fieldpath
- testdata
6 files changed
+82
-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 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
235 | 242 | | |
236 | 243 | | |
237 | 244 | | |
| |||
| 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 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
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