-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
35 lines (30 loc) · 989 Bytes
/
main.py
File metadata and controls
35 lines (30 loc) · 989 Bytes
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
from calls import *
from w3Obj import w3, w3ws
multiHttp = getMultiCall(w3)
multiWss = getMultiCall(w3ws)
def avg(ls):
tt = 0
for i in ls:
tt+=i
return tt/len(ls)
import time
avgtime = {"wss":[],"https":[]}
times = 50
import threading
for i in range(times):
print("run no." + str(i))
time_start = time.time() #開始計時
multiHttp()
time_end = time.time() #結束計時
time_c= time_end - time_start #執行所花時間
print('time cost', time_c, 's, using https')
avgtime["https"].append(time_c)
time_start = time.time() #開始計時
multiWss()
time_end = time.time() #結束計時
time_c= time_end - time_start #執行所花時間
print('time cost', time_c, 's, using websocket')
avgtime["wss"].append(time_c)
print(f"over {times} times of testing: ")
print(f"Average time spent on a http call is : {avg(avgtime['https'])}s")
print(f"Average time spent on a wss call is : {avg(avgtime['wss'])}s")