-
Notifications
You must be signed in to change notification settings - Fork 0
/
performance_test.py
50 lines (39 loc) · 1.24 KB
/
performance_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
import time
from fssp_protocol import FSSP
def sender():
data = "Sample data to be sent over by the FSSP protocol" * 20 # 470 bytes
conn = FSSP('localhost', 3000)
conn.connect('localhost', 2000)
conn.listen()
data_size = 0
start_time = time.time()
while True:
conn.send(data)
data_size += len(data)
print("sent: ", data_size, " Bytes", end="\r")
print("sent: {} Bytes - buffer: ({})".format(data_size, len(conn.sent_buffer)), end="\r")
if ((time.time() - start_time) >= 60):
print("\ntest finished")
message = "end"
conn.send(message)
break
def receiver():
conn = FSSP('localhost', 2000)
conn.connect('localhost', 3000)
conn.listen()
time_start = time.time()
data_size = 0
bandwidth = 0
while True:
data = conn.recv()
if (data == "end"):
print("\ntest finished")
break
data_size += len(data)
bandwidth = data_size / (time.time() - time_start)
print("bandwidth: {} B/s - buffer: ({})".format(str(bandwidth)[0:10], len(conn.recv_buffer)), end='\r')
mode = input("mode (1 - sender, 2 - receiver): ")
if (mode == '1'):
sender()
else:
receiver()