Speed test over 24h

Here is an easy one, a script that does a speed test every 5minutes. I made this when we were testing starlink out. We wanted to see when was the best time to download stuff and what kind of fluctuations were happening.

import speedtest
import datetime
import time
import pandas

pinged = 0
date_object = datetime.date.today()
now = datetime.datetime.now()
with open(f'speedtest_{date_object}.csv', "w") as f:
#288 = 24 hours of every 5 minutes
    while pinged < 288:
        #300 = every 5 minutes
        servers = []
        threads = None
        s = speedtest.Speedtest()
        s.get_servers(servers)
        s.get_best_server()
        downloads = s.download(threads=threads)
        uploads = s.upload(threads=threads)
        shares = s.results.share()
        results_dict = s.results.dict()
        print("test sent")
        f.write(f'Date: {now} Downloads: {downloads} Uploads: {uploads} /png: {shares}')
        f.write("\n")
        pinged = pinged + 1
        time.sleep(300)
    else:
        print("cannot reach")
    

With this we were able to get a good understanding of what were the best times for what and how reliable starlink was.