Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/entrypoint_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"load_level1",
"load_level3",
"serialize",
"load_page_50",
"instances_all",
"instances_sparse",
"deserialize_new_level1",
"deserialize_new_level3",
"deserialize_existing_level1",
Expand Down
37 changes: 37 additions & 0 deletions tests/src/tests/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,43 @@ def load_level3(self, count: str):
ic.print(f"BENCH_RESULT:load_level3:{count}:{cost}")
return cost

def load_page_50(self, count: str):
"""Measure cost of a cold load_some(1, 50) page at given DB size."""
self._clear()
count = int(count)
_seed_entities(count)
Database.get_instance().clear_registry()
cost, _ = _measure(lambda: BenchZone.load_some(1, 50))
ic.print(f"BENCH_RESULT:load_page_50:{count}:{cost}")
return cost

def instances_all(self, count: str):
"""Measure cost of a cold instances() scan with every id present."""
self._clear()
count = int(count)
_seed_entities(count)
Database.get_instance().clear_registry()
cost, _ = _measure(lambda: BenchZone.instances())
ic.print(f"BENCH_RESULT:instances_all:{count}:{cost}")
return cost

def instances_sparse(self, count: str):
"""Measure cost of a cold instances() scan after deleting every other zone.

With per-id probing every deleted id still costs a storage read; with a
range read deleted ids cost nothing.
"""
self._clear()
count = int(count)
_seed_entities(count)
for zone in BenchZone.load_some(1, max(count, 1)):
if int(zone._id) % 2 == 0:
zone.delete()
Database.get_instance().clear_registry()
cost, _ = _measure(lambda: BenchZone.instances())
ic.print(f"BENCH_RESULT:instances_sparse:{count}:{cost}")
return cost

def deserialize_new_level1(self, count: str):
"""Measure cost of deserialize (new entity) with level=1 at given DB size."""
self._clear()
Expand Down
Loading