-
Notifications
You must be signed in to change notification settings - Fork 1
/
system_stress_respond.py
86 lines (70 loc) · 3.21 KB
/
system_stress_respond.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
import requests
from lxml import html
from bs4 import BeautifulSoup
from time import time
from math import sqrt
from joblib import Parallel, delayed
##################3 please Change the domain name after Deployment (you can use freely ngrok server) ##########################
#domain_name='https://a331eae7648b.ngrok.io'
domain_name='http://127.0.0.1:8000/'
###############################################################################################################################
def single_request_home (domain_name):
requests.get(domain_name)
#print('one request sent')
#testing server response time get home for one person
start_time = time()
for i in range(1):
requests.get(domain_name)
end_time= time()
time_diff=end_time-start_time
print("=========================================")
print(f'testing server response time get home for one person : {time_diff}')
#test 10 requestes home bage at one time
start_time = time()
Parallel(n_jobs=10)(delayed(single_request_home)(domain_name) for i in range(10))
end_time= time()
time_diff=end_time-start_time
print("=========================================")
print(f'test 10 requestes home bage at one time : {time_diff}')
#test 20 requestes home bage at one time
start_time = time()
Parallel(n_jobs=10)(delayed(single_request_home)(domain_name) for i in range(20))
end_time= time()
time_diff=end_time-start_time
print("=========================================")
print(f'test 20 requestes home bage at one time : {time_diff}')
#test 1 requestes single_product bage at one time
start_time = time()
Parallel(n_jobs=10)(delayed(single_request_home)(f'{domain_name}/single_product/show_product/10') for i in range(1))
end_time= time()
time_diff=end_time-start_time
print("=========================================")
print(f'test 1 requestes single_product bage at one time : {time_diff}')
#test 10 requestes single_product bage at one time
start_time = time()
Parallel(n_jobs=10)(delayed(single_request_home)(f'{domain_name}/single_product/show_product/10') for i in range(10))
end_time= time()
time_diff=end_time-start_time
print("=========================================")
print(f'test 10 requestes single_product bage at one time : {time_diff}')
#test 20 requestes single_product bage at one time
start_time = time()
Parallel(n_jobs=10)(delayed(single_request_home)(f'{domain_name}/single_product/show_product/10') for i in range(20))
end_time= time()
time_diff=end_time-start_time
print("=========================================")
print(f'test 20 requestes single_product bage at one time : {time_diff}')
# stress testing 50 user at once request home bage
start_time = time()
Parallel(n_jobs=10)(delayed(single_request_home)(f'{domain_name}') for i in range(50))
end_time= time()
time_diff=end_time-start_time
print("=========================================")
print(f'stress testing 50 user at once request home bage : {time_diff}')
# stress testing 50 user at once request home bage
start_time = time()
Parallel(n_jobs=10)(delayed(single_request_home)(f'{domain_name}/single_product/show_product/10') for i in range(50))
end_time= time()
time_diff=end_time-start_time
print("=========================================")
print(f'stress testing 50 user at once request single_product bage : {time_diff}')