Better test prefixes

This commit is contained in:
Eric Eastwood 2022-08-19 02:35:29 -05:00
parent fd941cdcbf
commit 0dbc7501ab

View file

@ -94,7 +94,7 @@ class HaveSeenEventsTestCase(unittest.HomeserverTestCase):
)
self.event_ids.append(event_id)
# TODO: Remove me before mergin
# TODO: Remove me before merging
def test_benchmark(self):
import time
@ -132,15 +132,15 @@ class HaveSeenEventsTestCase(unittest.HomeserverTestCase):
with LoggingContext(name="test") as ctx:
def time_have_seen_events(test_index: int, event_ids):
def time_have_seen_events(test_prefix: str, event_ids):
benchmark_start_time = time.time()
remaining_event_ids = self.get_success(
self.store.have_seen_events(room_id, event_ids)
)
benchmark_end_time = time.time()
logger.info(
"Benchmark time%s: %s",
test_index,
"Benchmark time (%s): %s",
"{test_prefix: <13}".format(test_prefix=test_prefix),
(benchmark_end_time - benchmark_start_time),
)
self.assertIsNotNone(remaining_event_ids)
@ -148,13 +148,13 @@ class HaveSeenEventsTestCase(unittest.HomeserverTestCase):
event_ids_odd = event_ids[::2]
event_ids_even = event_ids[1::2]
time_have_seen_events(1, event_ids)
time_have_seen_events(2, event_ids)
time_have_seen_events(3, event_ids)
time_have_seen_events(4, event_ids_odd)
time_have_seen_events(5, event_ids_odd)
time_have_seen_events(6, event_ids_even)
time_have_seen_events(7, event_ids_even)
time_have_seen_events("1 cold cache", event_ids)
time_have_seen_events("2, warm cache", event_ids)
time_have_seen_events("3, warm cache", event_ids)
time_have_seen_events("4, odds", event_ids_odd)
time_have_seen_events("5, odds", event_ids_odd)
time_have_seen_events("6, evens", event_ids_even)
time_have_seen_events("7, evens", event_ids_even)
# that should result in a many db queries
self.assertEqual(ctx.get_resource_usage().db_txn_count, 1)