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:

1
$ curl https://blog.0x427567.com/

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:

1
$ curl -w %{time_total} https://blog.0x427567.com/

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

1
$ curl -o /dev/null -s -w %{time_total}\\n https://blog.0x427567.com/

-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.

1
$ curl -o /dev/null -s -w "Response Time: %{time_total}\\n" https://blog.0x427567.com/ > /tmp/curl.log

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