-
Notifications
You must be signed in to change notification settings - Fork 0
/
perfomance_test.py
93 lines (85 loc) · 2.48 KB
/
perfomance_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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import requests
from datetime import datetime
rest_get_time = datetime.now()
response = requests.get('http://127.0.0.1:8000/rest/pizza/')
end_response = datetime.now()
entries_count = len(response.json())
print(f'{entries_count} pizza entries by rest: {end_response - rest_get_time}')
graphql_get_time = datetime.now()
query = """
query {
allPizzas {
id,
name,
price
}
}
"""
requests.post('http://127.0.0.1:8000/graphql/', data={"query": query})
print(f'{entries_count} pizza entries with all fields by graphql: {datetime.now() - graphql_get_time}')
graphql_get_time = datetime.now()
query = """
query {
allPizzas {
id,
name,
}
}
"""
requests.post('http://127.0.0.1:8000/graphql/', data={"query": query})
print(f'{entries_count} pizza entries with id and name by graphql: {datetime.now() - graphql_get_time}')
graphql_get_time = datetime.now()
query = """
query {
allPizzas {
id
}
}
"""
requests.post('http://127.0.0.1:8000/graphql/', data={"query": query})
print(f'{entries_count} pizza entries with id by graphql: {datetime.now() - graphql_get_time}')
graphql_get_time = datetime.now()
query = """
query {
pizzasOptimized {
id
}
}
"""
requests.post('http://127.0.0.1:8000/graphql/', data={"query": query})
print(f'{entries_count} pizza entries with id by optimized graphql: {datetime.now() - graphql_get_time}')
rest_get_time = datetime.now()
response = requests.get('http://127.0.0.1:8000/rest/toppings/')
end_response = datetime.now()
entries_count = len(response.json())
print(f'{entries_count} toppings entries by rest: {end_response - rest_get_time}')
graphql_get_time = datetime.now()
query = """
query {
allToppings {
id,
name,
quantity,
pizza {
id,
name,
price
}
}
}
"""
requests.post('http://127.0.0.1:8000/graphql/', data={"query": query})
print(f'{entries_count} toppings entries with name and pizza name: {datetime.now() - graphql_get_time}')
graphql_get_time = datetime.now()
query = """
query {
toppingsOptimized {
name,
pizza {
name
}
}
}
"""
requests.post('http://127.0.0.1:8000/graphql/', data={"query": query})
print(f'{entries_count} toppings entries with name and pizza name optimized: {datetime.now() - graphql_get_time}')