-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_single_vs_multi.py
More file actions
30 lines (22 loc) · 856 Bytes
/
test_single_vs_multi.py
File metadata and controls
30 lines (22 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import time
import requests
from concurrent.futures import ThreadPoolExecutor, as_completed
# In web_client.c, change the THREAD_POOL_SIZE to 1 to test single vs multi.
def make_request():
local_start = time.perf_counter()
print("local start time = ", local_start)
response = requests.get(f"http://localhost:18000/index.html")
if response.status_code != 200:
print("ERROR OCCURED!")
local_end = time.perf_counter()
print("local end time = ", local_end)
return local_end - local_start
start = time.perf_counter()
idx = 1
with ThreadPoolExecutor() as executor:
results = [executor.submit(make_request) for _ in range(1000)]
for f in as_completed(results):
print(f"Thread {idx} execution time taken = ", f.result())
idx += 1
end = time.perf_counter()
print("total time taken ", end - start)