Last updated on October 24th, 2023 at 12:48 am
I like some fast way to test the connection speed from my local host or my server, so I often use this way to test the connect time speed.
time curl -o /dev/null -s -w "Connect: %{time_connect}s\nTTFB: %{time_starttransfer}s\nTotal time: %{time_total}s\n" [URL]
Replace [URL]
with the URL you want to test.
Here’s a breakdown of the command:
time
: This will measure the real elapsed time of the entire command.-o /dev/null
: Discards the output of the curl command.-s
: Makescurl
operate in “silent” mode where it doesn’t show progress or error messages.-w
: Allows you to format the output. In this case, we’re printing:Connect
: The time it took for the TCP connect to the server.TTFB (Time To First Byte)
: The time it took to get the first byte from the server after the TCP connect.Total time
: The total time the request took.
For example, to test the page speed of https://www.example.com
, you would use:
time curl -o /dev/null -s -w "Connect: %{time_connect}s\nTTFB: %{time_starttransfer}s\nTotal time: %{time_total}s\n" https://juzhax.com
After executing the command, you’ll see the connection time, TTFB, and total time it took to fetch the URL. The real
time from the time
command will also provide you with an overall idea of how long the command took to run.