-
Notifications
You must be signed in to change notification settings - Fork 2
/
tests-script.py
executable file
·41 lines (32 loc) · 1.12 KB
/
tests-script.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
#!/usr/bin/env python3
import pyspeedtest
import platform
import datetime
import json
import time
import os
TEST_NB = 50
BROWSERS = ["safari"]
BASE_DIR='test_' + datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S")
SLEEP=60
IFACE = 'en0'
if not os.path.exists(BASE_DIR):
os.makedirs(BASE_DIR)
for i in range(TEST_NB):
for b in BROWSERS:
print("Iteration:", i+1, "Browser:", b )
directory=BASE_DIR + '/{}_{}'.format(b,i)
if not os.path.exists(directory):
os.makedirs(directory)
try:
#result = pyspeedtest.run_speedtest(browser=b, pcap_path="{}/trace.pcap".format(directory), pcap_iface=IFACE)
result = pyspeedtest.run_speedtest(browser=b, pcap_path="/dev/null", pcap_iface=IFACE)
result['browser'] = b
result['iteration'] = i
result['time'] = time.time()
result['platform'] = platform.system()
json.dump(result, open("{}/result.json".format(directory),"w"))
except Exception as e:
print ("Error:", e
)
time.sleep(SLEEP)