-
Notifications
You must be signed in to change notification settings - Fork 0
/
analysis
42 lines (30 loc) · 829 Bytes
/
analysis
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
import speedtest
import time
servers = []
# If you want to test against a specific server
# servers = [1234]
threads = None
# If you want to use a single threaded test
# threads = 1
try:
s = speedtest.Speedtest()
s.get_servers(servers)
s.get_best_server()
s.download(threads=threads)
s.upload(threads=threads)
s.results.share()
data = s.results.dict()
ping = data['ping']
upload = data['upload'] /1000000
download = data['download'] /1000000
timestamp = time.time()
total = str(timestamp) + ',' +str(ping) + ',' +str(upload) + ',' + str(download) + '\n'
output = open('output.csv','a')
output.write(total)
output.close()
except speedtest.ConfigRetrievalError:
output = open('output.csv','a')
timestamp = time.time()
total = str(timestamp) + ',' + '0,0,0\n'
output.write(total)
output.close()