Curl统计页面各项性能指标

10 Jun 2015

网页加载慢的原因很多,比如DNS解析慢,与服务器延迟过高,传输带宽太小等。因此需要更信息的列举出每一步的时间,Curl可以很轻易的计算各个步骤的时间:

curl -s -w ‘\nLookup time:\t%{time_namelookup}\nConnect time:\t%{time_connect}\nAppCon time:\t%{time_appconnect}\nRedirect time:\t%{time_redirect}\nPreXfer time:\t%{time_pretransfer}\nStartXfer time:\t%{time_starttransfer}\n\nTotal time:\t%{time_total}\n’ -o /dev/null http://www.co-ding.com

结果如下

 Lookup time:0.270
 Connect time:0.479
 AppCon time:0.000
 Redirect time:0.000
 PreXfer time:0.479
 StartXfer time:0.981
 Total time:0.981