速度テストで正確なMBit / sを計算してください。

速度テストで正確なMBit / sを計算してください。

wget速度は一般的に要約に表示されることがわかります。しかし、小さなOpenWRTシェルから100MBをダウンロードするのにかかる時間をテストしたいと思います。

t=$(date +"%s")
wget http://speedtest.netcologne.de/test_100mb.bin -O ->/dev/null
echo -n "mBit/s:"; expr 8 \* 100 / $(($(date +"%s")-$t))

説明する:

  1. タイムスタンプを$ tに保存
  2. 100MBをダウンロードしても何も保存しない
  3. 計算する8 * 100mb / $t

実際にMBit / sを取得するには、より多くの計算を追加する必要がありますか?たぶん1.024を何回掛けたり分割したりするのでしょうか?

また、このリンクでは、wgetを使用したダウンロードが常に正確に100 MBではないことがわかりました。ファイルとして保存せずに正しいダウンロードMBサイズをどのように取得できますか?

ベストアンサー1

Content-Lengthすべてではありませんが、多くのサイトではタイトルフィールドにサイズを表示します。を使用してその情報を取得できますが、wget -Sダウンロードを無効にするオプションはないようです。 curl -Dこれもします。

ただし、lynxを使用してヘッダーを取得できます。たとえば、次のようになります。

$ lynx -dump -head http://speedtest.netcologne.de/test_100mb.bin
HTTP/1.1 404 Not Found
Server: nginx/1.6.2
Date: Sat, 13 Aug 2016 14:35:45 GMT
Content-Type: text/html
Content-Length: 168
Connection: close

これは以下より簡潔ですwget

$ wget -S http://speedtest.netcologne.de/test_100mb.bin
--2016-08-13 10:29:51--  http://speedtest.netcologne.de/test_100mb.bin
Resolving speedtest.netcologne.de (speedtest.netcologne.de)... 78.35.18.142
Connecting to speedtest.netcologne.de (speedtest.netcologne.de)|78.35.18.142|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 404 Not Found
  Server: nginx/1.6.2
  Date: Sat, 13 Aug 2016 14:29:51 GMT
  Content-Type: text/html
  Content-Length: 168
  Connection: keep-alive
2016-08-13 10:29:51 ERROR 404: Not Found.

提供されたURLが正しくありません。ライブウェブサイトの場合、より多くのことが発生します。

$ lynx -head -dump http://unix.stackexchange.com
HTTP/1.1 200 OK
Cache-Control: public, max-age=60
Content-Length: 77651
Content-Type: text/html; charset=utf-8
Expires: Sat, 13 Aug 2016 14:39:01 GMT
Last-Modified: Sat, 13 Aug 2016 14:38:01 GMT
X-Frame-Options: SAMEORIGIN
X-Request-Guid: 4da57e2b-c682-4e63-8fad-9415b23cd43e
Accept-Ranges: bytes
Date: Sat, 13 Aug 2016 14:38:01 GMT
Via: 1.1 varnish
Connection: close
X-Served-By: cache-iad2627-IAD
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1471099081.842119,VS0,VE17
Vary: *
X-DNS-Prefetch-Control: off
Set-Cookie: prov=31367c00-2e03-4760-79fe-d4e13e52792e; domain=.stackexchange.com; expires=Fri, 01-Jan-2055 00:00:00 GMT; path=/; HttpOnly

比較的

$ wget -S http://unix.stackexchange.com
--2016-08-13 10:38:51--  http://unix.stackexchange.com/
Resolving unix.stackexchange.com (unix.stackexchange.com)... 151.101.129.69, 151.101.193.69, 151.101.1.69, ...
Connecting to unix.stackexchange.com (unix.stackexchange.com)|151.101.129.69|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 200 OK
  Cache-Control: public, max-age=60
  Content-Type: text/html; charset=utf-8
  Expires: Sat, 13 Aug 2016 14:39:51 GMT
  Last-Modified: Sat, 13 Aug 2016 14:38:51 GMT
  X-Frame-Options: SAMEORIGIN
  X-Request-Guid: d7279b7d-1605-49dc-9851-4658308bf6b1
  Content-Length: 77662
  Accept-Ranges: bytes
  Date: Sat, 13 Aug 2016 14:38:51 GMT
  Via: 1.1 varnish
  Connection: keep-alive
  X-Served-By: cache-iad2633-IAD
  X-Cache: MISS
  X-Cache-Hits: 0
  X-Timer: S1471099131.339794,VS0,VE16
  Vary: *
  X-DNS-Prefetch-Control: off
  Set-Cookie: prov=77b452f3-9269-f933-e756-b4eb3010dc30 domain=.stackexchange.com; expires=Fri, 01-Jan-2055 00:00:00 GMT; path=/; HttpOnly
Length: 77662 (76K) [text/html]
Saving to: `index.html.1'

100%[======================================>] 77,662      --.-K/s   in 0.02s   

2016-08-13 10:38:51 (3.54 MB/s) - `index.html.1' saved [77662/77662]

おすすめ記事