-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunner
More file actions
executable file
·39 lines (32 loc) · 1.03 KB
/
runner
File metadata and controls
executable file
·39 lines (32 loc) · 1.03 KB
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
#!/usr/bin/env python3
import time
import requests
def get_latency(hops, tries=1000):
d = []
ctr = 0
while ctr < tries:
try:
print(ctr)
response = requests.get(f"https://n.kuly.cloud/{'/n'*(hops-1)}", timeout=10)
d.append(response.elapsed.total_seconds()*1000)
ctr += 1
except Exception as e:
print(e)
print("timeout")
avg = sum(d) / tries
sortedlist = sorted(list(d))
fivepercent = int(tries/20)
lowerquart = sortedlist[fivepercent]
median = sortedlist[int(tries/2)-1]
upperquart = sortedlist[19*fivepercent]
return (lowerquart, median, avg, upperquart)
def print_csv(file, maxhops):
f = open(file, "w")
for hops in range(0, maxhops+1):
print(f"Checking for hops {hops}")
times = get_latency(hops)
f.write(f"{hops},{times[0]},{times[1]},{times[2]},{times[3]}\n")
f.close()
# print(get_latency(20, body="x"*1000))
# print_csv(configs, "measurements.csv")
print_csv("timings.csv", 20)