vim curl-time.txt 添加以下内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | \n remote_ip: %{remote_ip}\n remote_port: %{remote_port}\n local_ip: %{local_ip}\n local_port: %{local_port}\n http: %{http_code}\n dns: %{time_namelookup}s\n redirect: %{time_redirect}s\n time_connect: %{time_connect}s\n time_appconnect: %{time_appconnect}s\n time_pretransfer: %{time_pretransfer}s\n time_starttransfer: %{time_starttransfer}s\n size_download: %{size_download}bytes\n speed_download: %{speed_download}B/s\n ----------\n time_total: %{time_total}s\n \n |
试一试:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | curl -w "@/Users/mac/Desktop/curl-time.txt" www.baidu.com <!DOCTYPE html> <!--STATUS OK--><html>*******</html> remote_ip: 180.101.49.12 #服务器ip remote_port: 80 #服务器端口 local_ip: 30.208.75.45 #本地ip local_port: 49200 #本地端口 http: 200 #http状态码 dns: 0.030925s #从开始到域名解析完成的时间 redirect: 0.000000s #所有重定向步骤(包括名称查找、连接、预传输和传输)所用的时间(秒)。显示多个重定向的完整执行时间。 time_connect: 0.069830s #从开始到tcp协议建立完成的时间 time_appconnect: 0.000000s #从开始到SSL/SSH/etc connect/handshake协议完成的时间 time_pretransfer: 0.070846s #从开始到文件传输即将开始 time_starttransfer: 0.114130s #从开始到第一个字节即将传输(time_starttransfer-time_pretransfer可以代表服务器处理的时间) size_download: 2381bytes #总下载量 speed_download: 20788.000B/s #下载平均速度 ---------- time_total: 0.114534s 也可以直接输出,不用格式化文件方式。例如: curl -w "time_total:%{time_total}" www.baidu.com |
如果这些环节还不够怎么办
man curl
找到:
-w, –write-out