def bench_change_value(b: BenchTimer) -> None: s = StringSource() pq: PyKeyedPQB[str, None] = PyKeyedPQB() for _ in range(10000): pq.add(next(s), random_01(), None) with b.time() as t: for _ in t: key = s.rand_existing() pq.change_value(key, random_01()) with b.offset() as t: for _ in t: key = s.rand_existing() random_01()
def bench_change_value(b: BenchTimer) -> None: s = StringSource() pq: pqdict[str, float] = pqdict() for _ in range(10000): pq.additem(next(s), random_01()) with b.time() as t: for _ in t: key = s.rand_existing() pq.updateitem(key, random_01()) with b.offset() as t: for _ in t: key = s.rand_existing() random_01()
def bench_add(b: BenchTimer) -> None: s = StringSource() s_offset = StringSource() pq: PyKeyedPQB[str, None] = PyKeyedPQB() for _ in range(10000): pq.add(next(s), random_01(), None) next(s_offset) with b.time() as t: for _ in t: pq.add(next(s), random_01(), None) with b.offset() as t: for _ in t: next(s_offset) random_01()
def bench_add(b: BenchTimer) -> None: s = StringSource() s_offset = StringSource() pq: pqdict[str, float] = pqdict() for _ in range(10000): pq.additem(next(s), random_01()) next(s_offset) with b.time() as t: for _ in t: pq.additem(next(s), random_01()) with b.offset() as t: for _ in t: next(s_offset) random_01()
def bench_pop(b: BenchTimer) -> None: s = StringSource() pq: PyKeyedPQB[str, None] = PyKeyedPQB() for _ in range(b.n + 10000): pq.add(next(s), random_01(), None) with b.time() as t: for _ in t: pq.pop() with b.offset() as t: for _ in t: pass
def bench_pop(b: BenchTimer) -> None: s = StringSource() pq: pqdict[str, float] = pqdict() for _ in range(b.n + 10000): pq.additem(next(s), random_01()) with b.time() as t: for _ in t: pq.popitem() with b.offset() as t: for _ in t: pass
def bench_remove(b: BenchTimer) -> None: s = StringSource() s_remove = StringSource() s_offset = StringSource() pq: PyKeyedPQB[str, None] = PyKeyedPQB() for _ in range(b.n + 10000): pq.add(next(s), random_01(), None) next(s_offset) with b.time() as t: for _ in t: key = next(s_remove) del pq[key] with b.offset() as t: for _ in t: key = next(s_offset)
def bench_remove(b: BenchTimer) -> None: s = StringSource() s_remove = StringSource() s_offset = StringSource() pq: pqdict[str, float] = pqdict() for _ in range(b.n + 10000): pq.additem(next(s), random_01()) next(s_offset) with b.time() as t: for _ in t: key = next(s_remove) del pq[key] with b.offset() as t: for _ in t: key = next(s_offset)