Skip to content

Commit 96f81a5

Browse files
committed
ADD: add performance measure example
1 parent 2243e32 commit 96f81a5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

examples/echo_client_perf.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import time
2+
3+
from cc.udp import UDP
4+
5+
6+
udp = UDP(recv_addr=("0.0.0.0", 8001), send_addr=("127.0.0.1", 8000))
7+
8+
counter = 0
9+
10+
udp.send("Hello, World: {counter}".encode())
11+
12+
while True:
13+
t = time.perf_counter()
14+
for i in range(1000):
15+
data = udp.recv()
16+
counter += 1
17+
udp.send(f"Hello, World: {counter}".encode())
18+
print(f"Round trip time: {time.perf_counter() - t:.4f} ms")
19+

0 commit comments

Comments
 (0)