-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlatency_test.py
43 lines (32 loc) · 1.07 KB
/
latency_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
43
from timeit import timeit
import requests
from faker import Faker
from zerok.client import ZKClient
from zerok.graphiso import GraphIsomorphism
fake = Faker()
problem = GraphIsomorphism()
server_url = "http://10.0.0.2:5000"
client = ZKClient(problem=problem, server_url=server_url)
def traditional_flow():
username, password = fake.email(), fake.password(length=16)
resp = requests.post(
f"{server_url}/register_traditional",
json={"username": username, "password": password},
)
resp.raise_for_status()
resp = requests.post(
f"{server_url}/login_traditional",
json={"username": username, "password": f"{password}wrong"},
)
# resp.raise_for_status()
def zk_flow():
username, password = fake.email(), fake.password(length=16)
ok, resp = client.register_user(username, password)
if not ok:
print(resp)
return
ok, resp = client.login_user(username, f"{password}wrong")
# if not ok:
# print(resp)
print(timeit(traditional_flow, number=100), "ms")
print(timeit(zk_flow, number=100), "ms")