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 --:--:-- 1204k

            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:  总的用时

你可能感兴趣的:(curl命令模拟浏览器响应时间分析)