Apple - macOS Terminal command to test Internet speed

There is a CLI version of Speedtest called, appropriately, speedtest-cli.

You can install it via Homebrew:

brew install speedtest-cli

It's also available via MacPorts

Just execute it by running the command:

$ speedtest-cli


Retrieving speedtest.net configuration...
Testing from ACME Cable (xxx.xxx.xxx.xxx)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by ServerPronto (Miami, FL) [22.39 km]: 25.419 ms 
Testing download speed............................................................
Download: 70.16 Mbit/s
Testing upload speed............................................................
.Upload: 5.92 Mbit/s

Install iPerf3 from the developer: iPerf - The ultimate speed test tool for TCP, UDP and SCTP. This is a stand-alone cli, which doesn't require brew or MacPorts.

In the Terminal enter:

iperf3 -c <server-ip>

to get the upload speed/bandwidth and:

iperf3 -c <server-ip> -R

to get the download speed/bandwidth

You can get some public iPerf servers here: Public iPerf3 servers. Other servers are available by searching for iperf/iperf3 servers with Google.

I have tested this one: https://speedtest.wtnet.de/ (while watching TV online) with the following results:

iperf3 -c speedtest.wtnet.de -p 5200 -P 10 -4
...
[SUM]   0.00-10.00  sec  12.1 MBytes  10.1 Mbits/sec                  sender
[SUM]   0.00-10.00  sec  10.9 MBytes  9.17 Mbits/sec                  receiver

iperf3 -c speedtest.wtnet.de -p 5200 -P 10 -4 -R
...
[SUM]   0.00-10.00  sec  54.2 MBytes  45.5 Mbits/sec  558             sender
[SUM]   0.00-10.00  sec  51.8 MBytes  43.5 Mbits/sec                  receiver

The 558 in the third sum is the number of retransmitted TCP segments (Retr)!