Find the Time to First Byte Using Curl

I was recently looking for an easy way to find the time to first byte (TTFB) for a given url using curl. I wanted to run some script based tests for a bunch of urls over time. I ended up coming up with the following:
curl -w "Connect time: %{time_connect} Time to first byte: %{time_starttransfer} Total time: %{time_total} \n" -o /dev/null [url to test]

This gives you something like the following:
curl -w "Connect time: %{time_connect} Time to first byte: %{time_starttransfer} Total time: %{time_total} \n" -o /dev/null www.google.com
Connect time: 0.402 Time to first byte: 0.453 Total time: 0.475

Hope this is useful to someone else.

This entry was posted in Code and tagged , , . Bookmark the permalink.

One Response to Find the Time to First Byte Using Curl

  1. Pingback: Timing Details With cURL | Joseph Scott

Leave a Reply

Your email address will not be published. Required fields are marked *