I am getting request timing info with curl using the --write-out
option as described in this article.
Here is example output from one of my requests:
time_namelookup: 0.031
time_connect: 0.328
time_appconnect: 1.560
time_pretransfer: 1.560
time_redirect: 0.000
time_starttransfer: 1.903
----------
time_total: 2.075
My question is: How can I determine how much time the server took processing the request? Is the answer:
time_starttransfer - time-connect
That is, the time from when the connection was established to when the server starting sending its response? That seems correct but I want to be sure.
Details about curl timing variables may be found here: http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html
time_starttransfer. http://curl.haxx.se/docs/manpage.html defines it as "The time, in. seconds, it took from the start until the first byte was just about to. be transferred." As I understand it, that means the end of the. processing of the request at the web server, and the departure of the.
Yes, (time_starttransfer - time-connect) is the time from the connect was noticed by curl until the first byte arrived. Do note that it also includes the transfer time so for a remote site it will be longer simply because of that.
I'd say that you're right, (time_starttransfer - time_connect) definitely is an amount of time server took to process the request.
However - I also wondered what is the difference between time_connect and time_pretransfer? (intrigued by @Schwartzie and @Cheeso comments)
By looking at several curl queries on the web I observed that sometimes they're equal and sometimes they're not.
Then I figured out (at least I believe so) that they differ only for HTTPS requests, cause server needs some time to decrypt ssl layer, which is not exactly the time spent by the target app but the time spent by server hosting the app/service.
The time to decrypt ssl (and to connect also, the one given in time_connect) is time_appconnect, and only when it's 0 (like for non-https requests) - time_connect and time_pretransfer are EQUAL, otherwise for https requests they differ, and for https time_pretransfer would be equal to time_appconnect (and not to time_connect).
Check the following two examples:
curl -kso /dev/null -w "time_connect=%{time_connect}, time_appconnect:%{time_appconnect}, time_pretransfer=%{time_pretransfer}\n" http://www.csh.rit.edu
curl -kso /dev/null -w "time_connect=%{time_connect}, time_appconnect:%{time_appconnect}, time_pretransfer=%{time_pretransfer}\n" https://www.csh.rit.edu
so I'd say that time_pretransfer is more precise to be used compared to time_connect since it'll respect ssl connections too, and maybe some other things I'm not aware of.
With all the previous being said, I'd say that more precise answer for the question:
would probably be:
as @Schwartzie already mentioned, I just wanted to understand why.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With