How to get response time with curl

September 23, 2016 1 Min

curl is a powerful tool help us send request to a website, for example:

$ curl

Today, I will tech you guys how to get response time with curl, first we need add -w or –write-out option and we need to know total time, full command likes below:

$ curl -w %{time_total}

Now total response time will append to end, but response time looks like response content, it’s ok, let’s add some options.

$ curl -o /dev/null -s -w %{time_total}\\n

-s will use silent mode, you will not see progress meter or error message, -o can assign output location, for this case I don’t need save any log so I assign output to /dev/null, \n just break line.

If you need save result to a log file, just assign path and file name.

$ curl -o /dev/null -s -w "Response Time: %{time_total}\\n" > /tmp/curl.log

Please let me know if you have any question, thanks!