curlでWebサイトのパフォーマンス測定

投稿日: 2014/06/22 1:56:22

テキスト ボックス

[mypc]$ more format-curl.txt
\n
url_effective        : %{url_effective}\n
http_code            : %{http_code}\n
http_connect         : %{http_connect}\n
time_namelookup      : %{time_namelookup}\n
time_connect         : %{time_connect}\n
time_pretransfer     : %{time_pretransfer}\n
time_starttransfer   : %{time_starttransfer}\n
time_redirect        : %{time_redirect}\n
time_total           : %{time_total}\n
-----------------------------------------------------------\n
size_download        : %{size_download}\n
speed_download       : %{speed_download}\n
[mypc]$
[mypc]$ more sample.sh
#!/bin/bash
URL=$1
curl -w "@format-curl.txt" -o /dev/null -L $URL
[mypc]$
[mypc]$ sample.sh http://foo.co.jp
url_effective        : http://foo.co.jp
http_code            : 200
http_connect         : 000
time_namelookup      : 0.001
time_connect         : 0.027
time_pretransfer     : 0.165
time_starttransfer   : 0.641
time_redirect        : 0.772
time_total           : 1.450
-----------------------------------------------------------
size_download        : 34322
speed_download       : 23672.000
手元にWindowsがないためMacからの実行結果ですが curlのライブラリーで、Webサイトパフォーマンスが測定できます。
DNS名前解決の時間、リダイレクトの時間、リクエストを出してからファーストバイトを受け取るまでの時間など。
Windowsの場合は、バッチやスクリプトを同じように作れば、Webサイトのダウンロード速度や詳細にブレイクダウンしてパフォーマンスが測定できます。