speedtest 是国外很流行的测速平台,可以直接在其网站上测试本地上行下行带宽,最近看到其提供了本地命令行工具,使用起来更加方便了。



首先需要到官网安装对应平台的 CLI 工具:https://www.speedtest.net/apps/cli

Linux 类系统可以直接在使用 apt/brew 等包管理工具方便的安装,Windows 下需要手动下载 exe 可执行文件使用。


brew tap teamookla/speedtest
brew update
brew install speedtest --force


sudo apt-get install gnupg1 apt-transport-https dirmngr
export INSTALL_KEY=379CE192D401AB61
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $INSTALL_KEY
echo "deb https://ookla.bintray.com/debian generic main" | sudo tee  /etc/apt/sources.list.d/speedtest.list
sudo apt-get update
sudo apt-get install speedtest

首先在网站上下载可执行文件,点击下载 1.0.0 版

可执行文件为 speedtest.exe,需要将其目录加入系统 PATH 路径才可以直接在 terminal 调用,加入 PATH 方法参考我的教程:https://blog.niekun.net/archives/413.html


在终端下使用 speedtest -h 命令查看帮助:

Speedtest by Ookla is the official command line client for testing the speed and performance of your internet connection.

Version: speedtest

Usage: speedtest [<options>]
  -h, --help                        Print usage information
  -V, --version                     Print version number
  -L, --servers                     List nearest servers
  -s, --server-id=#                 Specify a server from the server list using its id
  -I, --interface=ARG               Attempt to bind to the specified interface when connecting to servers
  -i, --ip=ARG                      Attempt to bind to the specified IP address when connecting to servers
  -o, --host=ARG                    Specify a server, from the server list, using its host's fully qualified domain name
  -p, --progress=yes|no             Enable or disable progress bar (Note: only available for 'human-readable'
                                    or 'json' and defaults to yes when interactive)
  -P, --precision=#                 Number of decimals to use (0-8, default=2)
  -f, --format=ARG                  Output format (see below for valid formats)
  -u, --unit[=ARG]                  Output unit for displaying speeds (Note: this is only applicable
                                    for ‘human-readable’ output format and the default unit is Mbps)
  -a                                Shortcut for [-u auto-decimal-bits]
  -A                                Shortcut for [-u auto-decimal-bytes]
  -b                                Shortcut for [-u auto-binary-bits]
  -B                                Shortcut for [-u auto-binary-bytes]
      --selection-details           Show server selection details
      --ca-certificate=ARG          CA Certificate bundle path
  -v                                Logging verbosity. Specify multiple times for higher verbosity
      --output-header               Show output header for CSV and TSV formats

 Valid output formats: human-readable (default), csv, tsv, json, jsonl, json-pretty

 Machine readable formats (csv, tsv, json, jsonl, json-pretty) use bytes as the unit of measure with max precision

 Valid units for [-u] flag:
   Decimal prefix, bits per second:  bps, kbps, Mbps, Gbps
   Decimal prefix, bytes per second: B/s, kB/s, MB/s, GB/s
   Binary prefix, bits per second:   kibps, Mibps, Gibps
   Binary prefix, bytes per second:  kiB/s, MiB/s, GiB/s
   Auto-scaled prefix: auto-binary-bits, auto-binary-bytes, auto-decimal-bits, auto-decimal-bytes

首先使用测试最近的测速节点 testspeed -L:

[email protected]:~# speedtest -L
Closest servers:

    ID  Name                           Location             Country
 29105  陕西移动5G                 Xi'an                China
  2461  China Unicom                   Chengdu              China
  4575  China Mobile Group Sichuan     Chengdu              China
 24337  China Mobile Group Sichuan Co.,Ltd. Chengdu              China
 35527  sccn                           Chengdu              China
 31985  China Unicom                   Chongqing            China
 17584  Chongqing Mobile Company       Chongqing            CN
  5530  CCN                            Chongqing            China
 16145  Lanzhou,China Mobile,Gansu     Lanzhou              China

执行 speedtest 命令进行测速,默认使用上面测试的最近的节点:

[email protected]:~# speedtest

   Speedtest by Ookla

     Server: Chongqing Mobile Company - Chongqing (id = 17584)
        ISP: China Telecom
    Latency:    31.45 ms   (25.47 ms jitter)
   Download:    14.31 Mbps (data used: 17.5 MB)
     Upload:     8.23 Mbps (data used: 11.3 MB)
Packet Loss:     0.0%
 Result URL: https://www.speedtest.net/result/c/bee17d45-7b9c-44e6-8a6e-ef99d84ba441


标签: none