(count)
| 272 | |
| 273 | print("Example 19") |
| 274 | def heap_overdue_benchmark(count): |
| 275 | def prepare(): |
| 276 | to_add = list(range(count)) |
| 277 | random.shuffle(to_add) |
| 278 | return [], to_add |
| 279 | |
| 280 | def run(queue, to_add): |
| 281 | for i in to_add: |
| 282 | heappush(queue, i) |
| 283 | while queue: |
| 284 | heappop(queue) |
| 285 | |
| 286 | return timeit.timeit( |
| 287 | setup="queue, to_add = prepare()", |
| 288 | stmt=f"run(queue, to_add)", |
| 289 | globals=locals(), |
| 290 | number=1, |
| 291 | ) |
| 292 | |
| 293 | |
| 294 | print("Example 20") |