Hatena::Grouptech

id:rx7(@namikawa)の技術メモ このページをアンテナに追加 RSSフィード

過去記事一覧 | Main Blog (元RX-7乗りの適当な日々) | SBM (id:rx7のBookmark)

2016/10/31

curlで取得できるレスポンスタイムの内訳

| curlで取得できるレスポンスタイムの内訳 - id:rx7(@namikawa)の技術メモ を含むブックマーク はてなブックマーク - curlで取得できるレスポンスタイムの内訳 - id:rx7(@namikawa)の技術メモ curlで取得できるレスポンスタイムの内訳 - id:rx7(@namikawa)の技術メモ のブックマークコメント

引用的なメモ。

Step 4: Print timing breakdown

But we still don’t see the timing breakdown of the HTTP request as promised. If we go through all the options supported by curl (http://curl.haxx.se/docs/manpage.html) we will see that it has the capability of returning timing information on the hostname lookup ( time_namelookup), the time it takes to connect to the remote host ( time_connect), the time it takes to start transferring data ( time_pretrasnfer), the total time ( total_time) and many others. In order to display this information on our console in a pretty and human readable format copy and paste the following command:

$ curl -L --output /dev/null --silent --show-error --write-out 'lookup:        %{time_namelookup}\nconnect:       %{time_connect}\nappconnect:    %{time_appconnect}\npretransfer:   %{time_pretransfer}\nredirect:      %{time_redirect}\nstarttransfer: %{time_starttransfer}\ntotal:         %{time_total}\n' 'google.com'
 lookup:        0.036
 connect:       0.053
 appconnect:    0.000
 pretransfer:   0.053
 redirect:      0.105
 starttransfer: 0.118
 total:         0.253

appconnect is the time, in seconds, it took from the start until the SSL/SSH/etc. connect/handshake to the remote host was completed. In the example above it is zero because we don’t use the HTTPS protocol. If you try the same command with “https://google.com” you get the following nonzero value for appconnect:

$ curl -L –output /dev/null –silent –show-error –write-out ‘lookup:        %{time_namelookup}\nconnect:       %{time_connect}\nappconnect:    %{time_appconnect}\npretransfer:   %{time_pretransfer}\nredirect:      %{time_redirect}\nstarttransfer: %{time_starttransfer}\ntotal:         %{time_total}\n’ ‘https://google.com’
lookup:        0.038
connect:       0.063
appconnect:    0.177
pretransfer:   0.178
redirect:      0.225
starttransfer: 0.679
total:         0.929
HTTP transaction timing breakdown with curl | NetBeez

まとめ

Here is what each value represents, according to curl’s manual page:

  • lookup: 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.
  • appconnect: 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. (Added in 7.12.3)
  • starttransfer: The time, in seconds, it took from the start until the first byte was just about to be transferred. This includes time_pretransfer 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.
HTTP transaction timing breakdown with curl | NetBeez
トラックバック - http://tech.g.hatena.ne.jp/rx7/20161031