1. 程式人生 > >curl命令模擬瀏覽器響應時間分析

curl命令模擬瀏覽器響應時間分析

1,首先需要本地有個format的檔案。方便對輸出格式化:

檔案內容如下:

\n
            time_namelookup:  %{time_namelookup}\n
               time_connect:  %{time_connect}\n
            time_appconnect:  %{time_appconnect}\n
           time_pretransfer:  %{time_pretransfer}\n
              time_redirect:  %{time_redirect}\n
            time_pretransfer:
%{time_pretransfer}\n time_starttransfer: %{time_starttransfer}\n ----------\n time_total: %{time_total}\n \n

2,然後執行如下命令:

 curl -lw  "@format" http://7ktr6y.com5.z0.glb.qiniucdn.com/liuhanlin-movi -o /dev/null

3,執行結果為:

liuhanlindemac:private yishiyaonie$ 
curl -lw "@format" http://7ktr6y.com5.z0.glb.qiniucdn.com/liuhanlin-movi -o /dev/null % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 19.8M 100 19.8M 0 0 662k 0 0:00:30 0:00:30 --:--:-- 1204
k time_namelookup: 0.035 time_connect: 0.048 time_appconnect: 0.000 time_pretransfer: 0.049 time_redirect: 0.000 time_pretransfer: 0.049 time_starttransfer: 0.164 ---------- time_total: 30.643
curl -Lw  "@format" "http://106.3.62.197/2015-09-27/1443362916818u2293430.mp4?wsiphost=local"  -H"Host:cdn.qupeiyin.cn" -o /dev/null

4.結果分析:

            time_namelookup:  dns解析時間
               time_connect:  建立連結時間
            time_appconnect:  0.000
              time_redirect:  跳轉時間
            time_pretransfer: 開始準備傳輸時間
         time_starttransfer:  開始傳輸時間
                            ----------
                 time_total:  總的用時