Revert "fix tiered results"

This reverts commit dbaf99af9e.
This commit is contained in:
Xuanzhe Han
2025-03-10 23:24:00 +00:00
parent dbaf99af9e
commit 44dd3592b0
2 changed files with 44 additions and 44 deletions

View File

@@ -9,6 +9,8 @@ from utils import print_report
baseurl = "http://localhost:8000"
chance_of_selecting_friend = 1
user_friends = json.loads(requests.get(baseurl + "/users_and_friends").content)
user_ids = json.loads(requests.get(baseurl + "/users").content)["ids"]
@@ -25,25 +27,23 @@ def generate_random_friend(user):
next_user = str(random.choice(user_friends[user]))
return next_user
for chance_of_selecting_friend in [0.25, 0.5, 0.75, 1.0]:
times = []
hits = []
times = []
hits = []
start = time.time()
curr_user = generate_random()
last_user = curr_user
for i in tqdm(range(10000)):
url = baseurl + "/user/" + curr_user
response = requests.get(url)
content = json.loads(response.content)
times.append(content["time_ms"])
hits.append(content["source"] == "cache")
if fetch_friend(chance_of_selecting_friend):
curr_user = generate_random_friend(last_user)
else:
curr_user = generate_random()
last_user = curr_user
end = time.time()
start = time.time()
curr_user = generate_random()
last_user = curr_user
for i in tqdm(range(10000)):
url = baseurl + "/user/" + curr_user
response = requests.get(url)
content = json.loads(response.content)
times.append(content["time_ms"])
hits.append(content["source"] == "cache")
if fetch_friend(chance_of_selecting_friend):
curr_user = generate_random_friend(last_user)
else:
curr_user = generate_random()
last_user = curr_user
end = time.time()
print_report(hits, times, end - start)
print_report(hits, times, end - start)