pairing_heap 3.0.1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +1 -1
- data/Gemfile.lock +37 -21
- data/README.md +244 -353
- data/Rakefile +2 -0
- data/lib/pairing_heap/version.rb +1 -1
- data/lib/pairing_heap.rb +30 -0
- data/pairing_heap.gemspec +3 -10
- metadata +8 -7
data/README.md
CHANGED
@@ -101,9 +101,12 @@ This API is a drop-in replacement of [lazy_priority_queue](https://github.com/ma
|
|
101
101
|
| dequeue | O(n) | O(log n) |
|
102
102
|
| * change_priority | O(1) | o(log n) |
|
103
103
|
| * delete | O(n) | O(log n) |
|
104
|
+
| ^ merge | O(1) | O(1) |
|
104
105
|
|
105
106
|
`*` Not available in `SimplePairingHeap`
|
106
107
|
|
108
|
+
`^` Only available in `SimplePairingHeap`
|
109
|
+
|
107
110
|
## Benchmarks
|
108
111
|
I picked the three fastest pure Ruby priority queue implementations I was aware of for the comparison:
|
109
112
|
|
@@ -117,7 +120,7 @@ Original performance test from [lazy_priority_queue](https://github.com/matiasba
|
|
117
120
|
> A stress test of 1,000,000 operations: starting with 1,000 pushes/0 pops, following 999 pushes/1 pop, and so on till 0 pushes/1000 pops.
|
118
121
|
<table>
|
119
122
|
<tr>
|
120
|
-
<th colspan="4">ruby 3.
|
123
|
+
<th colspan="4">ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin23]</th>
|
121
124
|
</tr>
|
122
125
|
<tr>
|
123
126
|
<th>Library</th>
|
@@ -127,36 +130,36 @@ Original performance test from [lazy_priority_queue](https://github.com/matiasba
|
|
127
130
|
</tr>
|
128
131
|
<tr>
|
129
132
|
<td>pairing_heap (SimplePairingHeap)</td>
|
130
|
-
<td>
|
131
|
-
<td>62.
|
132
|
-
<td>0.
|
133
|
+
<td>26</td>
|
134
|
+
<td>62.249427</td>
|
135
|
+
<td>0.419</td>
|
133
136
|
</tr>
|
134
137
|
<tr>
|
135
138
|
<td>pairing_heap (PairingHeap)</td>
|
136
|
-
<td>
|
137
|
-
<td>
|
138
|
-
<td>0.
|
139
|
+
<td>17</td>
|
140
|
+
<td>61.624806</td>
|
141
|
+
<td>0.276(1.52x slower)</td>
|
139
142
|
</tr>
|
140
143
|
<tr>
|
141
144
|
<td>rb_heap</td>
|
142
|
-
<td>
|
143
|
-
<td>
|
144
|
-
<td>0.
|
145
|
+
<td>16</td>
|
146
|
+
<td>63.656502</td>
|
147
|
+
<td>0.251(1.67x slower)</td>
|
145
148
|
</tr>
|
146
149
|
<tr>
|
147
150
|
<td>lazy_priority_queue</td>
|
148
|
-
<td>
|
149
|
-
<td>
|
150
|
-
<td>0.
|
151
|
+
<td>7</td>
|
152
|
+
<td>63.339192</td>
|
153
|
+
<td>0.111(3.79x slower)</td>
|
151
154
|
</tr>
|
152
155
|
<tr>
|
153
156
|
<td>Fibonacci</td>
|
154
|
-
<td>
|
155
|
-
<td>
|
156
|
-
<td>0.
|
157
|
+
<td>5</td>
|
158
|
+
<td>69.010737</td>
|
159
|
+
<td>0.073(5.77x slower)</td>
|
157
160
|
</tr>
|
158
161
|
<tr>
|
159
|
-
<th colspan="4">ruby 3.
|
162
|
+
<th colspan="4">ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +YJIT [x86_64-darwin23]</th>
|
160
163
|
</tr>
|
161
164
|
<tr>
|
162
165
|
<th>Library</th>
|
@@ -166,36 +169,36 @@ Original performance test from [lazy_priority_queue](https://github.com/matiasba
|
|
166
169
|
</tr>
|
167
170
|
<tr>
|
168
171
|
<td>pairing_heap (SimplePairingHeap)</td>
|
169
|
-
<td>
|
170
|
-
<td>60.
|
171
|
-
<td>0.
|
172
|
+
<td>39</td>
|
173
|
+
<td>60.725689</td>
|
174
|
+
<td>0.642</td>
|
172
175
|
</tr>
|
173
176
|
<tr>
|
174
177
|
<td>rb_heap</td>
|
175
|
-
<td>
|
176
|
-
<td>60.
|
177
|
-
<td>0.
|
178
|
+
<td>31</td>
|
179
|
+
<td>60.370348</td>
|
180
|
+
<td>0.514(1.25x slower)</td>
|
178
181
|
</tr>
|
179
182
|
<tr>
|
180
183
|
<td>pairing_heap (PairingHeap)</td>
|
181
|
-
<td>
|
182
|
-
<td>
|
183
|
-
<td>0.
|
184
|
+
<td>25</td>
|
185
|
+
<td>62.269577</td>
|
186
|
+
<td>0.402(1.6x slower)</td>
|
184
187
|
</tr>
|
185
188
|
<tr>
|
186
|
-
<td>
|
187
|
-
<td>
|
188
|
-
<td>
|
189
|
-
<td>0.
|
189
|
+
<td>lazy_priority_queue</td>
|
190
|
+
<td>9</td>
|
191
|
+
<td>62.144710</td>
|
192
|
+
<td>0.145(4.43x slower)</td>
|
190
193
|
</tr>
|
191
194
|
<tr>
|
192
|
-
<td>
|
193
|
-
<td>
|
194
|
-
<td>
|
195
|
-
<td>0.
|
195
|
+
<td>Fibonacci</td>
|
196
|
+
<td>8</td>
|
197
|
+
<td>65.064385</td>
|
198
|
+
<td>0.123(5.22x slower)</td>
|
196
199
|
</tr>
|
197
200
|
<tr>
|
198
|
-
<th colspan="4">jruby 9.
|
201
|
+
<th colspan="4">jruby 9.4.5.0 (3.1.4) 2023-11-02 1abae2700f OpenJDK 64-Bit Server VM 21+35-2513 on 21+35-2513 +indy +jit [x86_64-darwin]</th>
|
199
202
|
</tr>
|
200
203
|
<tr>
|
201
204
|
<th>Library</th>
|
@@ -205,36 +208,36 @@ Original performance test from [lazy_priority_queue](https://github.com/matiasba
|
|
205
208
|
</tr>
|
206
209
|
<tr>
|
207
210
|
<td>pairing_heap (SimplePairingHeap)</td>
|
208
|
-
<td>
|
209
|
-
<td>60.
|
210
|
-
<td>0.
|
211
|
+
<td>43</td>
|
212
|
+
<td>60.734661</td>
|
213
|
+
<td>0.709</td>
|
211
214
|
</tr>
|
212
215
|
<tr>
|
213
216
|
<td>rb_heap</td>
|
214
217
|
<td>34</td>
|
215
|
-
<td>
|
216
|
-
<td>0.
|
218
|
+
<td>61.677228</td>
|
219
|
+
<td>0.552(1.28x slower)</td>
|
217
220
|
</tr>
|
218
221
|
<tr>
|
219
222
|
<td>pairing_heap (PairingHeap)</td>
|
220
|
-
<td>
|
221
|
-
<td>61.
|
222
|
-
<td>0.
|
223
|
+
<td>28</td>
|
224
|
+
<td>61.284382</td>
|
225
|
+
<td>0.458(1.55x slower)</td>
|
223
226
|
</tr>
|
224
227
|
<tr>
|
225
228
|
<td>Fibonacci</td>
|
226
|
-
<td>
|
227
|
-
<td>
|
228
|
-
<td>0.
|
229
|
+
<td>22</td>
|
230
|
+
<td>61.396897</td>
|
231
|
+
<td>0.359(1.97x slower)</td>
|
229
232
|
</tr>
|
230
233
|
<tr>
|
231
234
|
<td>lazy_priority_queue</td>
|
232
|
-
<td>
|
233
|
-
<td>61.
|
234
|
-
<td>0.
|
235
|
+
<td>20</td>
|
236
|
+
<td>61.841463</td>
|
237
|
+
<td>0.324(2.19x slower)</td>
|
235
238
|
</tr>
|
236
239
|
<tr>
|
237
|
-
<th colspan="4">truffleruby
|
240
|
+
<th colspan="4">truffleruby 23.1.2, like ruby 3.2.2, Oracle GraalVM JVM [x86_64-darwin]</th>
|
238
241
|
</tr>
|
239
242
|
<tr>
|
240
243
|
<th>Library</th>
|
@@ -244,33 +247,33 @@ Original performance test from [lazy_priority_queue](https://github.com/matiasba
|
|
244
247
|
</tr>
|
245
248
|
<tr>
|
246
249
|
<td>pairing_heap (SimplePairingHeap)</td>
|
247
|
-
<td>
|
248
|
-
<td>60.
|
249
|
-
<td>3.
|
250
|
+
<td>202</td>
|
251
|
+
<td>60.225639</td>
|
252
|
+
<td>3.388</td>
|
250
253
|
</tr>
|
251
254
|
<tr>
|
252
255
|
<td>rb_heap</td>
|
253
|
-
<td>
|
254
|
-
<td>60.
|
255
|
-
<td>
|
256
|
+
<td>140</td>
|
257
|
+
<td>60.190881</td>
|
258
|
+
<td>2.357(1.44x slower)</td>
|
256
259
|
</tr>
|
257
260
|
<tr>
|
258
261
|
<td>pairing_heap (PairingHeap)</td>
|
259
|
-
<td>
|
260
|
-
<td>60.
|
261
|
-
<td>1.
|
262
|
+
<td>100</td>
|
263
|
+
<td>60.373610</td>
|
264
|
+
<td>1.692(2x slower)</td>
|
262
265
|
</tr>
|
263
266
|
<tr>
|
264
267
|
<td>lazy_priority_queue</td>
|
265
|
-
<td>
|
266
|
-
<td>
|
267
|
-
<td>0.
|
268
|
+
<td>31</td>
|
269
|
+
<td>61.179244</td>
|
270
|
+
<td>0.510(6.65x slower)</td>
|
268
271
|
</tr>
|
269
272
|
<tr>
|
270
273
|
<td>Fibonacci</td>
|
271
|
-
<td>
|
272
|
-
<td>
|
273
|
-
<td>0.
|
274
|
+
<td>11</td>
|
275
|
+
<td>64.413419</td>
|
276
|
+
<td>0.171(19.81x slower)</td>
|
274
277
|
</tr>
|
275
278
|
</table>
|
276
279
|
|
@@ -278,7 +281,7 @@ Original performance test from [lazy_priority_queue](https://github.com/matiasba
|
|
278
281
|
A stress test of 1,501,500 operations: starting with 1,000 pushes/1000 change_priorities/0 pops, following 999 pushes/999 change_priorities/1 pop, and so on till 0 pushes/0 change_priorities/1000 pops.
|
279
282
|
<table>
|
280
283
|
<tr>
|
281
|
-
<th colspan="4">ruby 3.
|
284
|
+
<th colspan="4">ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin23]</th>
|
282
285
|
</tr>
|
283
286
|
<tr>
|
284
287
|
<th>Library</th>
|
@@ -289,23 +292,23 @@ A stress test of 1,501,500 operations: starting with 1,000 pushes/1000 change_pr
|
|
289
292
|
<tr>
|
290
293
|
<td>pairing_heap</td>
|
291
294
|
<td>15</td>
|
292
|
-
<td>
|
293
|
-
<td>0.
|
295
|
+
<td>60.817878</td>
|
296
|
+
<td>0.247</td>
|
294
297
|
</tr>
|
295
298
|
<tr>
|
296
299
|
<td>lazy_priority_queue</td>
|
297
|
-
<td>
|
298
|
-
<td>
|
299
|
-
<td>0.
|
300
|
+
<td>7</td>
|
301
|
+
<td>63.990376s</td>
|
302
|
+
<td>0.109(2.26x slower)</td>
|
300
303
|
</tr>
|
301
304
|
<tr>
|
302
305
|
<td>Fibonacci</td>
|
303
|
-
<td>
|
304
|
-
<td>
|
305
|
-
<td>0.
|
306
|
+
<td>5</td>
|
307
|
+
<td>70.148980s</td>
|
308
|
+
<td>0.071(3.47x slower)</td>
|
306
309
|
</tr>
|
307
310
|
<tr>
|
308
|
-
<th colspan="4">ruby 3.
|
311
|
+
<th colspan="4">ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +YJIT [x86_64-darwin23]</th>
|
309
312
|
</tr>
|
310
313
|
<tr>
|
311
314
|
<th>Library</th>
|
@@ -315,24 +318,24 @@ A stress test of 1,501,500 operations: starting with 1,000 pushes/1000 change_pr
|
|
315
318
|
</tr>
|
316
319
|
<tr>
|
317
320
|
<td>pairing_heap</td>
|
318
|
-
<td>
|
319
|
-
<td>62.
|
320
|
-
<td>0.
|
321
|
+
<td>22</td>
|
322
|
+
<td>62.429264</td>
|
323
|
+
<td>0.353</td>
|
321
324
|
</tr>
|
322
325
|
<tr>
|
323
|
-
<td>
|
324
|
-
<td>
|
325
|
-
<td>63.
|
326
|
-
<td>0.
|
326
|
+
<td>lazy_priority_queue</td>
|
327
|
+
<td>9</td>
|
328
|
+
<td>63.464818</td>
|
329
|
+
<td>0.142(2.49x slower)</td>
|
327
330
|
</tr>
|
328
331
|
<tr>
|
329
|
-
<td>
|
330
|
-
<td>
|
331
|
-
<td>
|
332
|
-
<td>0.
|
332
|
+
<td>Fibonacci</td>
|
333
|
+
<td>8</td>
|
334
|
+
<td>67.908812</td>
|
335
|
+
<td>0.118(2.99x slower)</td>
|
333
336
|
</tr>
|
334
337
|
<tr>
|
335
|
-
<th colspan="4">jruby 9.
|
338
|
+
<th colspan="4">jruby 9.4.5.0 (3.1.4) 2023-11-02 1abae2700f OpenJDK 64-Bit Server VM 21+35-2513 on 21+35-2513 +indy +jit [x86_64-darwin]</th>
|
336
339
|
</tr>
|
337
340
|
<tr>
|
338
341
|
<th>Library</th>
|
@@ -342,24 +345,24 @@ A stress test of 1,501,500 operations: starting with 1,000 pushes/1000 change_pr
|
|
342
345
|
</tr>
|
343
346
|
<tr>
|
344
347
|
<td>pairing_heap</td>
|
345
|
-
<td>
|
346
|
-
<td>
|
347
|
-
<td>0.
|
348
|
+
<td>27</td>
|
349
|
+
<td>61.709517</td>
|
350
|
+
<td>0.438</td>
|
348
351
|
</tr>
|
349
352
|
<tr>
|
350
353
|
<td>Fibonacci</td>
|
351
|
-
<td>
|
352
|
-
<td>61.
|
353
|
-
<td>0.
|
354
|
+
<td>20</td>
|
355
|
+
<td>61.495636</td>
|
356
|
+
<td>0.326(1.34x slower)</td>
|
354
357
|
</tr>
|
355
358
|
<tr>
|
356
359
|
<td>lazy_priority_queue</td>
|
357
|
-
<td>
|
358
|
-
<td>
|
359
|
-
<td>0.
|
360
|
+
<td>19</td>
|
361
|
+
<td>63.401601</td>
|
362
|
+
<td>0.309(1.46x slower)</td>
|
360
363
|
</tr>
|
361
364
|
<tr>
|
362
|
-
<th colspan="4">truffleruby
|
365
|
+
<th colspan="4">truffleruby 23.1.2, like ruby 3.2.2, Oracle GraalVM JVM [x86_64-darwin]</th>
|
363
366
|
</tr>
|
364
367
|
<tr>
|
365
368
|
<th>Library</th>
|
@@ -369,21 +372,21 @@ A stress test of 1,501,500 operations: starting with 1,000 pushes/1000 change_pr
|
|
369
372
|
</tr>
|
370
373
|
<tr>
|
371
374
|
<td>pairing_heap</td>
|
372
|
-
<td>
|
373
|
-
<td>60.
|
374
|
-
<td>1.
|
375
|
+
<td>93</td>
|
376
|
+
<td>60.125750</td>
|
377
|
+
<td>1.577</td>
|
375
378
|
</tr>
|
376
379
|
<tr>
|
377
380
|
<td>lazy_priority_queue</td>
|
378
|
-
<td>
|
379
|
-
<td>
|
380
|
-
<td>0.
|
381
|
+
<td>26</td>
|
382
|
+
<td>62.372660s</td>
|
383
|
+
<td>0.419(3.77x slower)</td>
|
381
384
|
</tr>
|
382
385
|
<tr>
|
383
386
|
<td>Fibonacci</td>
|
384
|
-
<td>
|
385
|
-
<td>
|
386
|
-
<td>0.
|
387
|
+
<td>11</td>
|
388
|
+
<td>62.620172s</td>
|
389
|
+
<td>0.177(8.92x slower)</td>
|
387
390
|
</tr>
|
388
391
|
</table>
|
389
392
|
|
@@ -393,7 +396,7 @@ Start with 500 pushes, then:
|
|
393
396
|
* If does not support changing priority 500 push calls, then 1000 pops
|
394
397
|
<table>
|
395
398
|
<tr>
|
396
|
-
<th colspan="4">ruby 3.
|
399
|
+
<th colspan="4">ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin23]</th>
|
397
400
|
</tr>
|
398
401
|
<tr>
|
399
402
|
<th>Library</th>
|
@@ -401,26 +404,26 @@ Start with 500 pushes, then:
|
|
401
404
|
</tr>
|
402
405
|
<tr>
|
403
406
|
<td>pairing_heap (PairingHeap)</td>
|
404
|
-
<td>
|
407
|
+
<td>748.9</td>
|
405
408
|
</tr>
|
406
409
|
<tr>
|
407
410
|
<td>lazy_priority_queue</td>
|
408
|
-
<td>
|
411
|
+
<td>388.6(1.93x slower)</td>
|
409
412
|
</tr>
|
410
413
|
<tr>
|
411
414
|
<td>pairing_heap (SimplePairingHeap)</td>
|
412
|
-
<td>
|
415
|
+
<td>336.2(2.23x slower)</td>
|
413
416
|
</tr>
|
414
417
|
<tr>
|
415
418
|
<td>Fibonacci</td>
|
416
|
-
<td>
|
419
|
+
<td>225.9(3.31x slower)</td>
|
417
420
|
</tr>
|
418
421
|
<tr>
|
419
422
|
<td>rb_heap</td>
|
420
|
-
<td>
|
423
|
+
<td>215.2(3.48x slower)</td>
|
421
424
|
</tr>
|
422
425
|
<tr>
|
423
|
-
<th colspan="4">ruby 3.
|
426
|
+
<th colspan="4">ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +YJIT [x86_64-darwin23]</th>
|
424
427
|
</tr>
|
425
428
|
<tr>
|
426
429
|
<th>Library</th>
|
@@ -428,26 +431,26 @@ Start with 500 pushes, then:
|
|
428
431
|
</tr>
|
429
432
|
<tr>
|
430
433
|
<td>pairing_heap</td>
|
431
|
-
<td>
|
434
|
+
<td>1276</td>
|
432
435
|
</tr>
|
433
436
|
<tr>
|
434
|
-
<td>
|
435
|
-
<td>
|
437
|
+
<td>pairing_heap(SimplePairingHeap)</td>
|
438
|
+
<td>625.6(2.04x slower)</td>
|
436
439
|
</tr>
|
437
440
|
<tr>
|
438
441
|
<td>lazy_priority_queue</td>
|
439
|
-
<td>
|
442
|
+
<td>533.36(2.39x slower)</td>
|
440
443
|
</tr>
|
441
444
|
<tr>
|
442
|
-
<td>
|
443
|
-
<td>
|
445
|
+
<td>Fibonacci</td>
|
446
|
+
<td>495.519(2.57x slower)</td>
|
444
447
|
</tr>
|
445
448
|
<tr>
|
446
449
|
<td>rb_heap</td>
|
447
|
-
<td>
|
450
|
+
<td>453.323(2.81x slower)</td>
|
448
451
|
</tr>
|
449
452
|
<tr>
|
450
|
-
<th colspan="4">jruby 9.
|
453
|
+
<th colspan="4">jruby 9.4.5.0 (3.1.4) 2023-11-02 1abae2700f OpenJDK 64-Bit Server VM 21+35-2513 on 21+35-2513 +indy +jit [x86_64-darwin]</th>
|
451
454
|
</tr>
|
452
455
|
<tr>
|
453
456
|
<th>Library</th>
|
@@ -455,26 +458,26 @@ Start with 500 pushes, then:
|
|
455
458
|
</tr>
|
456
459
|
<tr>
|
457
460
|
<td>pairing_heap(PairingHeap)</td>
|
458
|
-
<td>
|
461
|
+
<td>1377</td>
|
459
462
|
</tr>
|
460
463
|
<tr>
|
461
464
|
<td>Fibonacci</td>
|
462
|
-
<td>
|
465
|
+
<td>1088(1.27x slower)</td>
|
463
466
|
</tr>
|
464
467
|
<tr>
|
465
468
|
<td>lazy_priority_queue</td>
|
466
|
-
<td>
|
469
|
+
<td>953.935(1.44x slower)</td>
|
467
470
|
</tr>
|
468
471
|
<tr>
|
469
472
|
<td>pairing_heap(SimplePairingHeap)</td>
|
470
|
-
<td>
|
473
|
+
<td>621.35(2.22x slower)</td>
|
471
474
|
</tr>
|
472
475
|
<tr>
|
473
476
|
<td>rb_heap</td>
|
474
|
-
<td>
|
477
|
+
<td>595.11(2.31x slower)</td>
|
475
478
|
</tr>
|
476
479
|
<tr>
|
477
|
-
<th colspan="4">truffleruby
|
480
|
+
<th colspan="4">truffleruby 23.1.2, like ruby 3.2.2, Oracle GraalVM JVM [x86_64-darwin]</th>
|
478
481
|
</tr>
|
479
482
|
<tr>
|
480
483
|
<th>Library</th>
|
@@ -482,135 +485,23 @@ Start with 500 pushes, then:
|
|
482
485
|
</tr>
|
483
486
|
<tr>
|
484
487
|
<td>pairing_heap(PairingHeap)</td>
|
485
|
-
<td>
|
488
|
+
<td>12712</td>
|
486
489
|
</tr>
|
487
490
|
<tr>
|
488
491
|
<td>pairing_heap(SimplePairingHeap)</td>
|
489
|
-
<td>
|
492
|
+
<td>9447(1.35x slower)</td>
|
490
493
|
</tr>
|
491
494
|
<tr>
|
492
495
|
<td>rb_heap</td>
|
493
|
-
<td>
|
494
|
-
</tr>
|
495
|
-
<tr>
|
496
|
-
<td>Fibonacci</td>
|
497
|
-
<td>1258(5.88x slower)</td>
|
498
|
-
</tr>
|
499
|
-
<tr>
|
500
|
-
<td>lazy_priority_queue</td>
|
501
|
-
<td>1004(7.38x slower)</td>
|
502
|
-
</tr>
|
503
|
-
</table>
|
504
|
-
|
505
|
-
### Dijkstra's algorithm with RGL [source code](./test/performance_rgl.rb)
|
506
|
-
<table>
|
507
|
-
<tr>
|
508
|
-
<th colspan="4">ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin21]</th>
|
509
|
-
</tr>
|
510
|
-
<tr>
|
511
|
-
<th>Library</th>
|
512
|
-
<th>Iterations</th>
|
513
|
-
<th>Seconds</th>
|
514
|
-
<th>Iterations per second</th>
|
515
|
-
</tr>
|
516
|
-
<tr>
|
517
|
-
<td>pairing_heap</td>
|
518
|
-
<td>9</td>
|
519
|
-
<td>61.469343</td>
|
520
|
-
<td>0.116</td>
|
521
|
-
</tr>
|
522
|
-
<tr>
|
523
|
-
<td>lazy_priority_queue</td>
|
524
|
-
<td>8</td>
|
525
|
-
<td>64.312672</td>
|
526
|
-
<td>0.125(1.18x slower)</td>
|
527
|
-
</tr>
|
528
|
-
<tr>
|
529
|
-
<td>Fibonacci</td>
|
530
|
-
<td>7</td>
|
531
|
-
<td>60.555716</td>
|
532
|
-
<td>0.116(1.27x slower)</td>
|
533
|
-
</tr>
|
534
|
-
<tr>
|
535
|
-
<th colspan="4">ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) +YJIT [x86_64-darwin21]</th>
|
536
|
-
</tr>
|
537
|
-
<tr>
|
538
|
-
<th>Library</th>
|
539
|
-
<th>Iterations</th>
|
540
|
-
<th>Seconds</th>
|
541
|
-
<th>Iterations per second</th>
|
542
|
-
</tr>
|
543
|
-
<tr>
|
544
|
-
<td>pairing_heap</td>
|
545
|
-
<td>10</td>
|
546
|
-
<td>65.160945s</td>
|
547
|
-
<td>0.154</td>
|
548
|
-
</tr>
|
549
|
-
<tr>
|
550
|
-
<td>Fibonacci</td>
|
551
|
-
<td>9</td>
|
552
|
-
<td>61.950587</td>
|
553
|
-
<td>0.145(1.06x slower)</td>
|
554
|
-
</tr>
|
555
|
-
<tr>
|
556
|
-
<td>lazy_priority_queue</td>
|
557
|
-
<td>9</td>
|
558
|
-
<td>66.592123</td>
|
559
|
-
<td>0.135(1.14x slower)</td>
|
560
|
-
</tr>
|
561
|
-
<tr>
|
562
|
-
<th colspan="4">jruby 9.3.7.0 (2.6.8) 2022-08-16 c79ef237e0 OpenJDK 64-Bit Server VM 17.0.2+8-86 on 17.0.2+8-86 +indy +jit [x86_64-darwin]</th>
|
563
|
-
</tr>
|
564
|
-
<tr>
|
565
|
-
<th>Library</th>
|
566
|
-
<th>Iterations</th>
|
567
|
-
<th>Seconds</th>
|
568
|
-
<th>Iterations per second</th>
|
569
|
-
</tr>
|
570
|
-
<tr>
|
571
|
-
<td>lazy_priority_queue</td>
|
572
|
-
<td>20</td>
|
573
|
-
<td>61.149944</td>
|
574
|
-
<td>0.328</td>
|
575
|
-
</tr>
|
576
|
-
<tr>
|
577
|
-
<td>pairing_heap</td>
|
578
|
-
<td>20</td>
|
579
|
-
<td>61.210225s</td>
|
580
|
-
<td>0.328</td>
|
496
|
+
<td>4009(3.17x slower)</td>
|
581
497
|
</tr>
|
582
498
|
<tr>
|
583
499
|
<td>Fibonacci</td>
|
584
|
-
<td>
|
585
|
-
<td>62.330882</td>
|
586
|
-
<td>0.292(1.12x slower)</td>
|
587
|
-
</tr>
|
588
|
-
<tr>
|
589
|
-
<th colspan="4">truffleruby 22.2.0, like ruby 3.0.3, GraalVM CE JVM [x86_64-darwin]</th>
|
590
|
-
</tr>
|
591
|
-
<tr>
|
592
|
-
<th>Library</th>
|
593
|
-
<th>Iterations</th>
|
594
|
-
<th>Seconds</th>
|
595
|
-
<th>Iterations per second</th>
|
596
|
-
</tr>
|
597
|
-
<tr>
|
598
|
-
<td>pairing_heap</td>
|
599
|
-
<td>59</td>
|
600
|
-
<td>60.053843</td>
|
601
|
-
<td>0.991</td>
|
500
|
+
<td>2793(4.55x slower)</td>
|
602
501
|
</tr>
|
603
502
|
<tr>
|
604
503
|
<td>lazy_priority_queue</td>
|
605
|
-
<td>
|
606
|
-
<td>60.586461</td>
|
607
|
-
<td>0.563(1.76x slower)</td>
|
608
|
-
</tr>
|
609
|
-
<tr>
|
610
|
-
<td>Fibonacci</td>
|
611
|
-
<td>31</td>
|
612
|
-
<td>60.633711</td>
|
613
|
-
<td>0.520(1.90x slower)</td>
|
504
|
+
<td>1188(10.7x slower)</td>
|
614
505
|
</tr>
|
615
506
|
</table>
|
616
507
|
|
@@ -618,7 +509,7 @@ Start with 500 pushes, then:
|
|
618
509
|
Heaps that support change_priority operation use it. Heaps that do not support it use dijkstra implementation that do not rely on change_priority instead and do additional pops and pushes instead(see Dijkstra-NoDec from [Priority Queues and Dijkstra’s Algorithm](https://www3.cs.stonybrook.edu/~rezaul/papers/TR-07-54.pdf)).
|
619
510
|
<table>
|
620
511
|
<tr>
|
621
|
-
<th colspan="4">ruby 3.
|
512
|
+
<th colspan="4">ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin23]</th>
|
622
513
|
</tr>
|
623
514
|
<tr>
|
624
515
|
<th>Library</th>
|
@@ -628,36 +519,36 @@ Heaps that support change_priority operation use it. Heaps that do not support i
|
|
628
519
|
</tr>
|
629
520
|
<tr>
|
630
521
|
<td>pairing_heap (SimplePairingHeap)</td>
|
631
|
-
<td>
|
632
|
-
<td>
|
633
|
-
<td>0.
|
522
|
+
<td>41</td>
|
523
|
+
<td>60.100316</td>
|
524
|
+
<td>0.682</td>
|
634
525
|
</tr>
|
635
526
|
<tr>
|
636
527
|
<td>pairing_heap (PairingHeap)</td>
|
637
|
-
<td>
|
638
|
-
<td>
|
639
|
-
<td>0.
|
528
|
+
<td>38</td>
|
529
|
+
<td>61.003607</td>
|
530
|
+
<td>0.623(1.09x slower)</td>
|
640
531
|
</tr>
|
641
532
|
<tr>
|
642
533
|
<td>rb_heap</td>
|
643
|
-
<td>
|
644
|
-
<td>
|
645
|
-
<td>0.
|
534
|
+
<td>30</td>
|
535
|
+
<td>61.486216</td>
|
536
|
+
<td>0.488(1.40x slower)</td>
|
646
537
|
</tr>
|
647
538
|
<tr>
|
648
539
|
<td>lazy_priority_queue</td>
|
649
|
-
<td>
|
650
|
-
<td>
|
651
|
-
<td>0.
|
540
|
+
<td>23</td>
|
541
|
+
<td>60.251764</td>
|
542
|
+
<td>0.382(1.79x slower)</td>
|
652
543
|
</tr>
|
653
544
|
<tr>
|
654
545
|
<td>Fibonacci</td>
|
655
|
-
<td>
|
656
|
-
<td>
|
657
|
-
<td>0.
|
546
|
+
<td>13</td>
|
547
|
+
<td>61.158622</td>
|
548
|
+
<td>0.213(3.21x slower)</td>
|
658
549
|
</tr>
|
659
550
|
<tr>
|
660
|
-
<th colspan="4">ruby 3.
|
551
|
+
<th colspan="4">ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +YJIT [x86_64-darwin23]</th>
|
661
552
|
</tr>
|
662
553
|
<tr>
|
663
554
|
<th>Library</th>
|
@@ -667,36 +558,36 @@ Heaps that support change_priority operation use it. Heaps that do not support i
|
|
667
558
|
</tr>
|
668
559
|
<tr>
|
669
560
|
<td>pairing_heap (SimplePairingHeap)</td>
|
670
|
-
<td>
|
671
|
-
<td>
|
672
|
-
<td>
|
561
|
+
<td>65</td>
|
562
|
+
<td>60.805882</td>
|
563
|
+
<td>1.070</td>
|
673
564
|
</tr>
|
674
565
|
<tr>
|
675
566
|
<td>pairing_heap (PairingHeap)</td>
|
676
|
-
<td>
|
677
|
-
<td>60.
|
678
|
-
<td>0.
|
567
|
+
<td>60</td>
|
568
|
+
<td>60.790842</td>
|
569
|
+
<td>0.987(1.08x slower)</td>
|
679
570
|
</tr>
|
680
571
|
<tr>
|
681
572
|
<td>rb_heap</td>
|
682
|
-
<td>
|
683
|
-
<td>60.
|
684
|
-
<td>0.
|
573
|
+
<td>54</td>
|
574
|
+
<td>60.917679</td>
|
575
|
+
<td>0.887(1.21x slower)</td>
|
685
576
|
</tr>
|
686
577
|
<tr>
|
687
|
-
<td>
|
688
|
-
<td>
|
689
|
-
<td>
|
690
|
-
<td>0.
|
578
|
+
<td>lazy_priority_queue</td>
|
579
|
+
<td>30</td>
|
580
|
+
<td>60.712786</td>
|
581
|
+
<td>0.495(2.16x slower)</td>
|
691
582
|
</tr>
|
692
583
|
<tr>
|
693
|
-
<td>
|
694
|
-
<td>
|
695
|
-
<td>
|
696
|
-
<td>0.
|
584
|
+
<td>Fibonacci</td>
|
585
|
+
<td>24</td>
|
586
|
+
<td>61.900715</td>
|
587
|
+
<td>0.388(2.76x slower)</td>
|
697
588
|
</tr>
|
698
589
|
<tr>
|
699
|
-
<th colspan="4">jruby 9.
|
590
|
+
<th colspan="4">jruby 9.4.5.0 (3.1.4) 2023-11-02 1abae2700f OpenJDK 64-Bit Server VM 21+35-2513 on 21+35-2513 +indy +jit [x86_64-darwin]</th>
|
700
591
|
</tr>
|
701
592
|
<tr>
|
702
593
|
<th>Library</th>
|
@@ -705,37 +596,37 @@ Heaps that support change_priority operation use it. Heaps that do not support i
|
|
705
596
|
<th>Iterations per second</th>
|
706
597
|
</tr>
|
707
598
|
<tr>
|
708
|
-
<td>
|
709
|
-
<td>
|
710
|
-
<td>
|
711
|
-
<td>
|
599
|
+
<td>rb_heap</td>
|
600
|
+
<td>70</td>
|
601
|
+
<td>60.077928</td>
|
602
|
+
<td>1.168</td>
|
712
603
|
</tr>
|
713
604
|
<tr>
|
714
|
-
<td>
|
715
|
-
<td>
|
716
|
-
<td>60.
|
717
|
-
<td>
|
605
|
+
<td>pairing_heap (SimplePairingHeap)</td>
|
606
|
+
<td>66</td>
|
607
|
+
<td>60.420935</td>
|
608
|
+
<td>1.094(1.07x slower)</td>
|
718
609
|
</tr>
|
719
610
|
<tr>
|
720
611
|
<td>pairing_heap (PairingHeap)</td>
|
721
|
-
<td>
|
722
|
-
<td>60.
|
723
|
-
<td>
|
612
|
+
<td>64</td>
|
613
|
+
<td>60.114467</td>
|
614
|
+
<td>1.066(1.1x slower)</td>
|
724
615
|
</tr>
|
725
616
|
<tr>
|
726
617
|
<td>Fibonacci</td>
|
727
|
-
<td>
|
728
|
-
<td>
|
729
|
-
<td>0.
|
618
|
+
<td>54</td>
|
619
|
+
<td>60.426971</td>
|
620
|
+
<td>0.898(1.30x slower)</td>
|
730
621
|
</tr>
|
731
622
|
<tr>
|
732
623
|
<td>lazy_priority_queue</td>
|
733
|
-
<td>
|
734
|
-
<td>
|
735
|
-
<td>0.
|
624
|
+
<td>49</td>
|
625
|
+
<td>60.636963</td>
|
626
|
+
<td>0.809(1.44x slower)</td>
|
736
627
|
</tr>
|
737
628
|
<tr>
|
738
|
-
<th colspan="4">truffleruby
|
629
|
+
<th colspan="4">truffleruby 23.1.2, like ruby 3.2.2, Oracle GraalVM JVM [x86_64-darwin]</th>
|
739
630
|
</tr>
|
740
631
|
<tr>
|
741
632
|
<th>Library</th>
|
@@ -745,33 +636,33 @@ Heaps that support change_priority operation use it. Heaps that do not support i
|
|
745
636
|
</tr>
|
746
637
|
<tr>
|
747
638
|
<td>pairing_heap (SimplePairingHeap)</td>
|
748
|
-
<td>
|
749
|
-
<td>60.
|
750
|
-
<td>
|
639
|
+
<td>288</td>
|
640
|
+
<td>60.102278</td>
|
641
|
+
<td>4.936</td>
|
751
642
|
</tr>
|
752
643
|
<tr>
|
753
644
|
<td>pairing_heap (PairingHeap)</td>
|
754
|
-
<td>
|
755
|
-
<td>60.
|
756
|
-
<td>
|
645
|
+
<td>232</td>
|
646
|
+
<td>60.159057</td>
|
647
|
+
<td>3.936(1.25x slower)</td>
|
757
648
|
</tr>
|
758
649
|
<tr>
|
759
650
|
<td>rb_heap</td>
|
760
|
-
<td>
|
761
|
-
<td>60.
|
762
|
-
<td>
|
651
|
+
<td>227</td>
|
652
|
+
<td>60.082482</td>
|
653
|
+
<td>3.881(1.27x slower)</td>
|
763
654
|
</tr>
|
764
655
|
<tr>
|
765
656
|
<td>Fibonacci</td>
|
766
|
-
<td>
|
767
|
-
<td>60.
|
768
|
-
<td>
|
657
|
+
<td>101</td>
|
658
|
+
<td>60.076691</td>
|
659
|
+
<td>1.721(2.87x slower)</td>
|
769
660
|
</tr>
|
770
661
|
<tr>
|
771
662
|
<td>lazy_priority_queue</td>
|
772
|
-
<td>
|
773
|
-
<td>
|
774
|
-
<td>
|
663
|
+
<td>66</td>
|
664
|
+
<td>60.771569</td>
|
665
|
+
<td>1.1(4.49x slower)</td>
|
775
666
|
</tr>
|
776
667
|
</table>
|
777
668
|
|
@@ -779,7 +670,7 @@ Heaps that support change_priority operation use it. Heaps that do not support i
|
|
779
670
|
#### Change priority required
|
780
671
|
<table>
|
781
672
|
<tr>
|
782
|
-
<th colspan="4">ruby 3.
|
673
|
+
<th colspan="4">ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin23]</th>
|
783
674
|
</tr>
|
784
675
|
<tr>
|
785
676
|
<th>Library</th>
|
@@ -791,14 +682,14 @@ Heaps that support change_priority operation use it. Heaps that do not support i
|
|
791
682
|
</tr>
|
792
683
|
<tr>
|
793
684
|
<td>lazy_priority_queue</td>
|
794
|
-
<td>
|
685
|
+
<td>2.1x slower</td>
|
795
686
|
</tr>
|
796
687
|
<tr>
|
797
688
|
<td>Fibonacci</td>
|
798
|
-
<td>
|
689
|
+
<td>3.38x slower</td>
|
799
690
|
</tr>
|
800
691
|
<tr>
|
801
|
-
<th colspan="4">ruby 3.
|
692
|
+
<th colspan="4">ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +YJIT [x86_64-darwin23]</th>
|
802
693
|
</tr>
|
803
694
|
<tr>
|
804
695
|
<th>Library</th>
|
@@ -809,15 +700,15 @@ Heaps that support change_priority operation use it. Heaps that do not support i
|
|
809
700
|
<td>1</td>
|
810
701
|
</tr>
|
811
702
|
<tr>
|
812
|
-
<td>
|
813
|
-
<td>
|
703
|
+
<td>lazy_priority_queue</td>
|
704
|
+
<td>2.55x slower</td>
|
814
705
|
</tr>
|
815
706
|
<tr>
|
816
|
-
<td>
|
817
|
-
<td>
|
707
|
+
<td>Fibonacci</td>
|
708
|
+
<td>2.74x slower</td>
|
818
709
|
</tr>
|
819
710
|
<tr>
|
820
|
-
<th colspan="4">jruby 9.
|
711
|
+
<th colspan="4">jruby 9.4.5.0 (3.1.4) 2023-11-02 1abae2700f OpenJDK 64-Bit Server VM 21+35-2513 on 21+35-2513 +indy +jit [x86_64-darwin]</th>
|
821
712
|
</tr>
|
822
713
|
<tr>
|
823
714
|
<th>Library</th>
|
@@ -829,14 +720,14 @@ Heaps that support change_priority operation use it. Heaps that do not support i
|
|
829
720
|
</tr>
|
830
721
|
<tr>
|
831
722
|
<td>Fibonacci</td>
|
832
|
-
<td>1.
|
723
|
+
<td>1.267x slower</td>
|
833
724
|
</tr>
|
834
725
|
<tr>
|
835
726
|
<td>lazy_priority_queue</td>
|
836
|
-
<td>1.
|
727
|
+
<td>1.396x slower</td>
|
837
728
|
</tr>
|
838
729
|
<tr>
|
839
|
-
<th colspan="4">truffleruby
|
730
|
+
<th colspan="4">truffleruby 23.1.2, like ruby 3.2.2, Oracle GraalVM JVM [x86_64-darwin]</th>
|
840
731
|
</tr>
|
841
732
|
<tr>
|
842
733
|
<th>Library</th>
|
@@ -848,18 +739,18 @@ Heaps that support change_priority operation use it. Heaps that do not support i
|
|
848
739
|
</tr>
|
849
740
|
<tr>
|
850
741
|
<td>lazy_priority_queue</td>
|
851
|
-
<td>3.
|
742
|
+
<td>3.54x slower</td>
|
852
743
|
</tr>
|
853
744
|
<tr>
|
854
745
|
<td>Fibonacci</td>
|
855
|
-
<td>
|
746
|
+
<td>5.86x slower</td>
|
856
747
|
</tr>
|
857
748
|
</table>
|
858
749
|
|
859
750
|
#### Change priority not required
|
860
751
|
<table>
|
861
752
|
<tr>
|
862
|
-
<th colspan="4">ruby 3.
|
753
|
+
<th colspan="4">ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin23]</th>
|
863
754
|
</tr>
|
864
755
|
<tr>
|
865
756
|
<th>Library</th>
|
@@ -871,22 +762,22 @@ Heaps that support change_priority operation use it. Heaps that do not support i
|
|
871
762
|
</tr>
|
872
763
|
<tr>
|
873
764
|
<td>pairing_heap (PairingHeap)</td>
|
874
|
-
<td>1.
|
765
|
+
<td>1.29x slower</td>
|
875
766
|
</tr>
|
876
767
|
<tr>
|
877
768
|
<td>rb_heap</td>
|
878
|
-
<td>1.
|
769
|
+
<td>1.53x slower</td>
|
879
770
|
</tr>
|
880
771
|
<tr>
|
881
772
|
<td>lazy_priority_queue</td>
|
882
|
-
<td>2.
|
773
|
+
<td>2.6x slower</td>
|
883
774
|
</tr>
|
884
775
|
<tr>
|
885
776
|
<td>Fibonacci</td>
|
886
|
-
<td>
|
777
|
+
<td>4.29x slower</td>
|
887
778
|
</tr>
|
888
779
|
<tr>
|
889
|
-
<th colspan="4">ruby 3.
|
780
|
+
<th colspan="4">ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +YJIT [x86_64-darwin23]</th>
|
890
781
|
</tr>
|
891
782
|
<tr>
|
892
783
|
<th>Library</th>
|
@@ -896,24 +787,24 @@ Heaps that support change_priority operation use it. Heaps that do not support i
|
|
896
787
|
<td>pairing_heap (SimplePairingHeap)</td>
|
897
788
|
<td>1</td>
|
898
789
|
</tr>
|
899
|
-
<tr>
|
900
|
-
<td>pairing_heap (PairingHeap)</td>
|
901
|
-
<td>1.348x slower</td>
|
902
|
-
</tr>
|
903
790
|
<tr>
|
904
791
|
<td>rb_heap</td>
|
905
|
-
<td>1.
|
792
|
+
<td>1.227x slower</td>
|
906
793
|
</tr>
|
907
794
|
<tr>
|
908
|
-
<td>
|
909
|
-
<td>1.
|
795
|
+
<td>pairing_heap (PairingHeap)</td>
|
796
|
+
<td>1.316x slower</td>
|
910
797
|
</tr>
|
911
798
|
<tr>
|
912
799
|
<td>lazy_priority_queue</td>
|
913
|
-
<td>
|
800
|
+
<td>3.094x slower</td>
|
801
|
+
</tr>
|
802
|
+
<tr>
|
803
|
+
<td>Fibonacci</td>
|
804
|
+
<td>3.79x slower</td>
|
914
805
|
</tr>
|
915
806
|
<tr>
|
916
|
-
<th colspan="4">jruby 9.
|
807
|
+
<th colspan="4">jruby 9.4.5.0 (3.1.4) 2023-11-02 1abae2700f OpenJDK 64-Bit Server VM 21+35-2513 on 21+35-2513 +indy +jit [x86_64-darwin]</th>
|
917
808
|
</tr>
|
918
809
|
<tr>
|
919
810
|
<th>Library</th>
|
@@ -921,26 +812,26 @@ Heaps that support change_priority operation use it. Heaps that do not support i
|
|
921
812
|
</tr>
|
922
813
|
<tr>
|
923
814
|
<td>pairing_heap (SimplePairingHeap)</td>
|
924
|
-
<td>1</td>
|
815
|
+
<td>1.033x slower</td>
|
925
816
|
</tr>
|
926
817
|
<tr>
|
927
818
|
<td>rb_heap</td>
|
928
|
-
<td>1.
|
819
|
+
<td>1.133x slower</td>
|
929
820
|
</tr>
|
930
821
|
<tr>
|
931
822
|
<td>pairing_heap (PairingHeap)</td>
|
932
|
-
<td>1.
|
823
|
+
<td>1.302x slower</td>
|
933
824
|
</tr>
|
934
825
|
<tr>
|
935
826
|
<td>Fibonacci</td>
|
936
|
-
<td>1.
|
827
|
+
<td>1.602x slower</td>
|
937
828
|
</tr>
|
938
829
|
<tr>
|
939
830
|
<td>lazy_priority_queue</td>
|
940
|
-
<td>
|
831
|
+
<td>1.777x slower</td>
|
941
832
|
</tr>
|
942
833
|
<tr>
|
943
|
-
<th colspan="4">truffleruby
|
834
|
+
<th colspan="4">truffleruby 23.1.2, like ruby 3.2.2, Oracle GraalVM JVM [x86_64-darwin]</th>
|
944
835
|
</tr>
|
945
836
|
<tr>
|
946
837
|
<th>Library</th>
|
@@ -951,20 +842,20 @@ Heaps that support change_priority operation use it. Heaps that do not support i
|
|
951
842
|
<td>1</td>
|
952
843
|
</tr>
|
953
844
|
<tr>
|
954
|
-
<td>
|
955
|
-
<td>1.
|
845
|
+
<td>rb_heap</td>
|
846
|
+
<td>1.35x slower</td>
|
956
847
|
</tr>
|
957
848
|
<tr>
|
958
|
-
<td>
|
959
|
-
<td>1.
|
849
|
+
<td>pairing_heap (PairingHeap)</td>
|
850
|
+
<td>1.58x slower</td>
|
960
851
|
</tr>
|
961
852
|
<tr>
|
962
853
|
<td>lazy_priority_queue</td>
|
963
|
-
<td>
|
854
|
+
<td>5.46x slower</td>
|
964
855
|
</tr>
|
965
856
|
<tr>
|
966
857
|
<td>Fibonacci</td>
|
967
|
-
<td>
|
858
|
+
<td>7.54x slower</td>
|
968
859
|
</tr>
|
969
860
|
</table>
|
970
861
|
|