curl -L --output /dev/null --silent --show-error -w \
'\nhttp code: %{http_code}
namelookup: %{time_namelookup}
connect: %{time_connect}
sslhandshake: %{time_appconnect}
pretransfer: %{time_pretransfer}
redirect: %{time_redirect}
firstbyte: %{time_starttransfer}
total: %{time_total}\n' \
http://www.baidu.com
# -v 选项,--verbose,指定该选项后,可以跟踪URL的连接信息。
# 加上选项后返回的信息,包括很多重要信息:
# 域名解析过程:我们可以得到真正连接的IP地址和端口
# 请求头信息:其中有使用的协议(HTTP),协议的请求方式(GET)
# 回应头信息:包含状态码,内容格式、长度等
说明
%{http_code},接口状态码
%{time_total}, 从开始到请求完毕的时间,响应完毕
%{time_namelookup},从开始到dns解析完成的时间
%{time_connect},从开始到链接完成的时间
%{time_pretransfer}, 从开始到请求开始传输的时间
%{time_appconnect}, 从开始到tls,ssl建立链接完毕的时间
%{time_starttransfer},从开始到第一个字节开始传输的时间
namelookup – The time, in seconds, it took from the start until the name resolving was completed.
connect – The time, in seconds, it took from the start until the TCP connect to the remote host(or proxy) was completed.#
sslhandshake – The time, in seconds, it took from the start until the SSL/SSH/etc connect/handshake to the remote host was completed. (Added in 7.19.0)
pretransfer – The time, in seconds, it took from the start until the file transfer was just about to begin. This includes all pre-transfer commands and negotiations that are specific to the particular protocol(s) involved.
redirect – The time, in seconds, it took for all redirection steps include name lookup,connect,pretransfer and transfer before the final transaction was started. time_redirect shows the complete execution time for multiple redirections.
firstbyte – The time, in seconds, it took from the start until the first byte was just about to be transferred. This includes time_pre-transfer and also the time the server needed to calculate the result.
total – The total time, in seconds, that the full operation lasted. The time will be displayed with millisecond resolution.
机翻
namelookup - 从开始到完成名称解析所需的时间,以秒为单位。
connect - 从开始到完成与远程主机(或代理)的TCP连接所花费的时间,以秒为单位。
sslhandshake - 从开始到完成与远程主机的SSL/SSH/等连接/握手所花费的时间,以秒为单位。(在7.19.0中添加)
pretransfer - 从开始到文件传输即将开始所花费的时间,以秒为单位。这包括所有传输前的命令和特定协议所涉及的协商。
redirect - 所有重定向步骤的时间,以秒为单位,包括名称查找,连接,预传输和传输之前的最终事务开始。
firstbyte - 从开始到第一个字节即将被传输的时间,以秒为单位。这包括time_pre-transfer,也包括服务器需要计算结果的时间。
total - 整个操作所持续的总时间,以秒为单位。时间将以毫秒的分辨率显示。