測試過在MT7688上也能用,(測速時7688 CPU 接近滿載)。
首先來安裝
pip install speedtest-cli
接下來你可以試用一下
speedtest
執行結果如下
boywhyde-Mac-mini:~ boywhychen$ speedtest
Retrieving speedtest.net configuration...
Testing from TWM Broadband (122.254.0.39)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by TFN Media Co., Ltd. (Kaohsiung) [8.27 km]: 15.02 ms
Testing download speed................................................................................
Download: 5.55 Mbit/s
Testing upload speed....................................................................................................
Upload: 2.78 Mbit/s
boywhyde-Mac-mini:~ boywhychen$
看起來我的網速沒有灌水
如果你要用在程式中呼叫取值,可以多下一個參數將內容轉換成JSON包裝
speedtest --json
執行結果如下 ,不過用JSON格式會得到原始bit/s的資料,不會將速度轉換成Mbit/s
boywhyde-Mac-mini:~ boywhychen$ speedtest --json
{"download": 5544023.1582899, "timestamp": "2017-02-11T16:26:39.586203", "ping": 15.59, "upload": 2433976.4864097824, "server": {"latency": 15.59, "name": "Kaohsiung", "url": "http://phc-sptest.elinx.com.tw/speedtest/upload.php", "country": "Taiwan", "lon": "120.2667", "cc": "TW", "host": "phc-sptest.elinx.com.tw:8080", "sponsor": "TFN Media Co., Ltd.", "url2": "http://phc-speedtest.elinx.com.tw/speedtest/upload.php", "lat": "22.6333", "id": "2189", "d": 8.274083461500231}}
boywhyde-Mac-mini:~ boywhychen$
接下來我們還可以透過參數將選擇最近的Server ID,滅少接數Server List時間
boywhychen$ speedtest --server 2189
我們發現它少了以下動作
Retrieving speedtest.net server list...
Selecting best server based on ping...
boywhyde-Mac-mini:~ boywhychen$ speedtest --server 2189
Retrieving speedtest.net configuration...
Testing from TWM Broadband (122.254.0.39)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by TFN Media Co., Ltd. (Kaohsiung) [8.27 km]: 80.888 ms
Testing download speed................................................................................
Download: 5.55 Mbit/s
Testing upload speed....................................................................................................
Upload: 2.51 Mbit/s
來看一下在Mac上Run 可以節省多少時間
(我在高雄,所以我以剛才回傳的JSON字串中的ID 做為固定的Server,若在不同
地點,建議先取得一次測試的JSON資料,拿到最好的Server ID再進行固定ID)
boywhyde-Mac-mini:~ boywhychen$ time speedtest
Retrieving speedtest.net configuration...
Testing from TWM Broadband (122.254.0.39)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Taiwan Fixed Network (Kaohsiung) [8.27 km]: 22.037 ms
Testing download speed................................................................................
Download: 5.53 Mbit/s
Testing upload speed....................................................................................................
Upload: 2.75 Mbit/s
real 0m25.164s
user 0m0.781s
sys 0m0.535s
boywhyde-Mac-mini:~ boywhychen$ time speedtest --server 2189
Retrieving speedtest.net configuration...
Testing from TWM Broadband (122.254.0.39)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by TFN Media Co., Ltd. (Kaohsiung) [8.27 km]: 13.183 ms
Testing download speed................................................................................
Download: 5.40 Mbit/s
Testing upload speed....................................................................................................
Upload: 2.85 Mbit/s
real 0m22.581s
user 0m0.688s
sys 0m0.530s一共節省了3秒鐘的時間在下載及找尋最好的Server。好像沒啥FU,來試試看在7688上
會節省多少時間呢 ?
root@mylinkit:~# time speedtest
Retrieving speedtest.net configuration...
Testing from TWM Broadband (122.254.0.39)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by TFN Media Co., Ltd. (Kaohsiung) [8.27 km]: 27.69 ms
Testing download speed................................................................................
Download: 5.50 Mbit/s
Testing upload speed....................................................................................................
Upload: 2.00 Mbit/s
real 0m 36.32s
user 0m 16.00s
sys 0m 1.85s
root@mylinkit:~# time speedtest --server 2189
Retrieving speedtest.net configuration...
Testing from TWM Broadband (122.254.0.39)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by TFN Media Co., Ltd. (Kaohsiung) [8.27 km]: 22.885 ms
Testing download speed................................................................................
Download: 5.50 Mbit/s
Testing upload speed....................................................................................................
Upload: 2.01 Mbit/s
real 0m 31.56s
user 0m 12.31s
sys 0m 1.48s
root@mylinkit:~#
在7688上測試,指定Server可以節省近5秒鐘,且測試節果和Mac測試的差不多,
雖然上傳稍微慢了一點,但如果有一個需要監控網路速度需求的話,7688小而省丫。
參考資料:
https://github.com/sivel/speedtest-cli
沒有留言:
張貼留言