惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Hacker News
The Hacker News
C
Cisco Blogs
P
Privacy & Cybersecurity Law Blog
Cloudbric
Cloudbric
S
Security Affairs
PCI Perspectives
PCI Perspectives
The Last Watchdog
The Last Watchdog
AWS News Blog
AWS News Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
N
News and Events Feed by Topic
W
WeLiveSecurity
T
Tenable Blog
L
LINUX DO - 最新话题
T
Tor Project blog
Help Net Security
Help Net Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Proofpoint News Feed
爱范儿
爱范儿
O
OpenAI News
Hacker News - Newest:
Hacker News - Newest: "LLM"
Y
Y Combinator Blog
I
Intezer
C
Check Point Blog
Stack Overflow Blog
Stack Overflow Blog
Recent Announcements
Recent Announcements
Google DeepMind News
Google DeepMind News
S
Securelist
P
Privacy International News Feed
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
V
Vulnerabilities – Threatpost
Schneier on Security
Schneier on Security
量子位
SecWiki News
SecWiki News
L
Lohrmann on Cybersecurity
T
Threat Research - Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
M
MIT News - Artificial intelligence
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Scott Helme
Scott Helme
H
Help Net Security
Vercel News
Vercel News
云风的 BLOG
云风的 BLOG
Spread Privacy
Spread Privacy
Know Your Adversary
Know Your Adversary
I
InfoQ
TaoSecurity Blog
TaoSecurity Blog
Blog — PlanetScale
Blog — PlanetScale
N
News | PayPal Newsroom
小众软件
小众软件
C
CERT Recently Published Vulnerability Notes

NickChenyx's Blog

Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish Create_Rubbish
Create_Rubbish
nickChen · 2018-04-18 · via NickChenyx's Blog

curl 实战

Created At :

Count:402 Views 👀 :

  1. 耗时分析

耗时分析

$ man curl  # 查看 curl 的使用方式

-w, --write-out <format> # -w 参数配置输出格式

-w 参数中有部分时间相关的参数如下:

  • time_namelookup:从请求开始到 DNS 域名解析完成的耗时
  • time_connect:从请求开始到 TCP 连接建立耗时(三次握手)
  • time_appconnect:从请求开始到 SSL/SSH 等建立连接耗时( ssl handshake 等)
  • time_pretransfer:从请求开始到响应开始传输的时间
  • time_redirect:从请求开始到,包含前面四者耗时,且所有重定向的时间相加,直到最终访问目标服务前的耗时
  • time_starttransfer:从请求开始到第一个字节将要传输的耗时,包含了 time_pretransfer 耗时
  • time_total:请求的全部耗时

如何发起耗时分析请求

  1. 直接在命令行中拼写输出格式
    curl -w '\ntime_namelookup=%{time_namelookup}\ntime_connect=%{time_connect}\ntime_appconnect=%{time_appconnect}\ntime_redirect=%{time_redirect}\ntime_pretransfer=%{time_pretransfer}\ntime_starttransfer=%{time_starttransfer}\ntime_total=%{time_total}\n\n' -o /dev/null -s -L 'http://voidchen.com'
  1. 利用文件描述格式
    创建一个格式文件 format.txt
     time_namelookup:  %{time_namelookup}\n
        time_connect:  %{time_connect}\n
     time_appconnect:  %{time_appconnect}\n
       time_redirect:  %{time_redirect}\n
    time_pretransfer:  %{time_pretransfer}\n
    time_starttransfer:  %{time_starttransfer}\n
                     ----------\n
          time_total:  %{time_total}\n
    使用格式文件发起访问
    curl -w '@format.txt' -o /dev/null -s -L 'http://voidchen.com'

耗时计算

  1. DNS耗时 = time_namelookup
  2. TCP建连耗时 = time_connect - time_namelookup
  3. SSL握手耗时 = time_appconnect - time_connect
  4. 服务器处理请求耗时 = time_starttransfer - time_pretransfer
  5. TTFB耗时 = time_starttransfer - time_appconnect
  6. 服务器传输耗时 = time_total - time_starttransfer
  7. 总耗时 = time_total

TODO 分析脚本

参考


转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 nickchenyx@gmail.com

Title:curl 实战

Count:402

Author:nickChen

Created At:2022-10-14, 22:19:41

Updated At:2023-05-08, 23:27:10

Url:http://nickchenyx.github.io/2022/10/14/curl_usage/

Copyright: 'Attribution-non-commercial-shared in the same way 4.0' Reprint please keep the original link and author.