Created
May 26, 2017 06:19
-
-
Save bfgits/e5e35d5a4732c7eebcada2ce716d2fb8 to your computer and use it in GitHub Desktop.
使用Curl命令查看请求响应时间方法
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -o /dev/null -s -w %{time_namelookup}::%{time_connect}::%{time_starttransfer}::%{time_total}::%{speed_download}"\n" http://www.minniapp.net | |
time_namelookup:DNS 解析域名www.36nu.com的时间 | |
time_commect:client和server端建立TCP 连接的时间 | |
time_starttransfer:从client发出请求;到web的server 响应第一个字节的时间 | |
time_total:client发出请求;到web的server发送会所有的相应数据的时间 | |
speed_download:下周速度 单位 byte/s | |
上面这条命令及返回结果可以这么理解: | |
0.014: DNS 服务器解析www.36nu.com 的时间单位是s | |
0.015: client发出请求,到c/s 建立TCP 的时间;里面包括DNS解析的时间 | |
0.018: client发出请求;到s响应发出第一个字节开始的时间;包括前面的2个时间 | |
0.019: client发出请求;到s把响应的数据全部发送给client;并关闭connect的时间 | |
1516256.00 :下载数据的速度 | |
建立TCP连接到server返回client第一个字节的时间:0.018s – 0.015s = 0.003s | |
server把响应数据发送给client的时间:0.019s – 0.018 = 0.01s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
curl-time() {
curl -so /dev/null -w "
HTTP CODE: %{http_code}\n\n
namelookup: %{time_namelookup}s\n
connect: %{time_connect}s\n
appconnect: %{time_appconnect}s\n
pretransfer: %{time_pretransfer}s\n
redirect: %{time_redirect}s\n
starttransfer: %{time_starttransfer}s\n
-------------------------\n
total: %{time_total}s\n" "$@"
}