Measure Internet Speed In Python Using Speedtest-cli

6

SpeedTest.net is an excellent website that lets you measure internet speed from your Raspberry Pi. It’s useful for checking the performance either for fault finding purposes or to see if you are getting the service promised by your ISP.

Matt Martz has created a Python project called speedtest-cli which allows you to do a basic upload/download measurement using SpeedNet’s infrastructure. It works fine on the Pi and is really easy to try out on the command line.

Installation

Downloading the utility is easy if you clone the projects git repository :

git clone https://github.com/sivel/speedtest-cli.git

Running SpeedTest

To run the script you need to navigate to the directory :

cd speedtest-cli

and then run the Python script using Python 3 :

python3 speedtest.py

The script will run and you should see something like this :

Measure Internet Speed with speedtest-cli

If you add –share to the command like this :

python speedtest_cli.py --share

it will create a link to an online image showing your results which you can share with your friends/family/enemies.

speedtest-cli with share option

Here’s my result using WiFi on a Pi 3 :

and with Ethernet :

The improved Ethernet bandwidth of the Pi 3 B+ gives a massive difference over previous models.


If you haven’t ever visited SpeedTest.net give it a try on your PC, Mac or laptop. Be sure to hit the oval “Begin Test” button in the centre of the page map rather than other buttons which may be adverts.

Share.

6 Comments

  1. How did you manage to get 85mbps on the PI?! i have Virgin 152mbps and the max i get is 15mbp through the speed test on the pi but on my laptop get over a 100+

  2. when I did the setup it worked for months, but suddenly it stopped working .I get an error that says something like there is no server to test or the code can’t locate a server to test. too bad, because it was a really nice project. I don’t know if speedtest blocked the connection. maybe.

    • I’ve just updated this blog. Delete your speedtest-cli directory and re-download. The main script has changed name to “speedtest.py” but I’ve just tried it on a Pi 3 and worked OK in both Python 2 and Python 3.

Leave A Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.