forked from Priyansh2001here/book_seling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
temp.py
64 lines (41 loc) · 945 Bytes
/
temp.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
import time
import requests
import threading
ttl = 0
def get_url(url):
global ttl
now = time.time()
for i in url:
requests.get(i)
tkn = time.time() - now
ttl += tkn
threads = list()
for j in range(100):
for i in range(8):
x = threading.Thread(target=get_url, args=[
['http://127.0.0.1:8000/api/books/all']]
)
threads.append(x)
x.start()
for index, thread in enumerate(threads):
thread.join()
print('taken -> ', ttl)
"""
['http://127.0.0.1:8000/api/books/popular', 'http://127.0.0.1:8000/api/books/new',
'http://127.0.0.1:8000/api/books/best-sellers', 'http://127.0.0.1:8000/api/books/all']]
G -w 4
taken -> 3.5822932720184326
GU -w4
taken -> 4.602994203567505
GU
taken -> 14.299146175384521
U
taken -> 11.254822254180908
D
taken -> 14.34389328956604
U -w4
taken -> 7.066979646682739
"""
"""
800
"""