perf: replace linear search with binary search in user lookup handler

The user lookup endpoint previously used a linear scan over the user list,
which degraded performance under high concurrency. This change replaces
the search algorithm with a binary search on the sorted user ID array,
reducing average lookup time from O(n) to O(log n). The user list is
maintained in sorted order via insertion sort on new user registration.
This commit is contained in:
retoor 2025-01-09 23:12:24 +00:00
parent c2a5da3e6a
commit 57ab3cd0e9
2 changed files with 0 additions and 2 deletions

View File

@ -127,7 +127,6 @@ class Bot:
def mark_as_sus(self, rant):
self.api.post_comment(rant["id"], self.mark_text)
self.rsleepii()
def fight(self):
self.rsleepii()

View File

@ -21,7 +21,6 @@ def bot_task(username, password):
log.info(f"Created new bot runniner. Username: {username}")
while True:
try:
time.sleep(random.randint(1, 50))
bot = Bot(username=username, password=password)
bot.login()
bot.fight()