12

I'm looking for a simple tool or built-in command that will allow me to measure with millisecond accuracy the time it takes to fetch a remote web page from a given URL.

GJ.
  • 9,673
  • 26
  • 74
  • 115

4 Answers4

12

Does this do what you're looking for?

time wget http://example.com
Dennis Williamson
  • 106,229
  • 19
  • 167
  • 187
  • This will include the time it takes to start and run wget, which can be significantly longer than the server's response time. – Paul Lynch May 27 '16 at 15:10
  • @PaulLynch: I did a simple test. I ran this in one terminal: `rm foo; touch foo; python -m SimpleHTTPServer` and in another: `time wget --quiet --output-document=/dev/null localhost:8000/foo` and the result was 2 milliseconds. I ran the same `wget` against google.com (which retrieves about 10K characters) and got about a quarter of a second. So let's call the start/run time about 1% in that case. Then, for comparison, I did `time curl file://foo` and got about 4 milliseconds. – Dennis Williamson May 27 '16 at 16:26
  • It seems you are right, for http requests-- for which I get only about 2ms of slowdown. I was trying to get an https URL. For that, wget is about 25ms slower for a request Chrome returns in about 10ms (and not "from cache"). Both wget and Chrome are running on the same machine as the webserver, and are addressing it as "localhost", so I blame wget for the time difference. – Paul Lynch May 31 '16 at 15:33
7

Httping will do that.

Httping is like 'ping' but for http-requests. Give it an url, and it'll show you how long it takes to connect, send a request and retrieve the reply (only the headers). Be aware that the transmission across the network also takes time! So it measures the latency of the webserver + network.

Tamara Wijsman
  • 57,083
  • 27
  • 185
  • 256
garyjohn
  • 34,610
  • 8
  • 97
  • 89
4

You can do it with curl as per this answer

Create a new file, curl-format.txt, and paste in:

    time_namelookup:  %{time_namelookup}\n
       time_connect:  %{time_connect}\n
    time_appconnect:  %{time_appconnect}\n
   time_pretransfer:  %{time_pretransfer}\n
      time_redirect:  %{time_redirect}\n
 time_starttransfer:  %{time_starttransfer}\n
                    ----------\n
         time_total:  %{time_total}\n

Then run curl like this:

curl -w "@curl-format.txt" -o /dev/null -s "http://wordpress.com/"

Harry Wood
  • 143
  • 1
  • 6
3

Wireshark will let you examine a transfer in a lot of detail. You can see how long it takes to download a single file, as Dennis suggested, or if you open the URL in a web browser, you can see how long it takes to load all of the related files (images, scripts, etc).

Neil
  • 442
  • 3
  • 9