-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_test.py
42 lines (34 loc) · 1.02 KB
/
run_test.py
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
31
32
33
34
35
36
37
38
39
40
41
42
import itertools
import time
from starlette.testclient import TestClient
import pandas as pd
from app.main import create_app
N = 30
client = TestClient(create_app())
files = ["1kb", "10kb", "100kb", "1mb"]
FUNCS = [
"1_return__dict__none__none",
"2_return__dict__pydantic__none",
"3_return__pydantic__pydantic__none",
"4_return__dict__pydantic__json",
"5_return__dict__none__orjson",
"6_return__dict__pydantic__orjson",
"7_return__pydantic__pydantic__orjson",
"8_return__pydantic__pydantic__pydantic_json_response",
]
results = {}
for name, file in itertools.product(FUNCS, files):
t0 = time.time()
for _ in range(N):
r = client.get(name, params={"file": file})
assert r.status_code == 200
t1 = time.time()
v = 1000 * (t1 - t0) / N
if file in results:
results[file][name] = v
else:
results[file] = {name: v}
from tabulate import tabulate
pd.set_option("display.max_columns", None)
df = pd.DataFrame(results)
print(df.to_markdown(floatfmt=".0f"))