DEV Community

Hannah (she/her)
Hannah (she/her)

Posted on

1 1

Measuring Web Requests with Httping

I recently encountered a bug where an http request was taking up to 3 seconds. Once I developed a potential solution, I needed to test the request to see if it was faster with the new code changes. In order to test, I developed a baseline by curling the request without any code changes. Next, I updated the code with the hopeful solution and curled the request again to observe the change.

Below is an example. Note, the -v (short for -verbose) shows extra information, like the runtime, which shows the length of the request in seconds.

curl -v http://api.citybik.es/v2/networks

I found myself curling repeatedly to check the length of the request. I even recorded the times and averaged them. This was cumbersome. Fortunately, I discovered a useful program called httping that allows you to test the latency of a request by pinging it on a loop. When you exit the loop, an average runtime is provided for you.

httping http://api.citybik.es/v2/networks

httping-demo

It's worth checking out the man pages because there are a number other useful httping features. For example, the demo below enables color highlighting and highlights all requests above the provided threshold.

httping http://api.citybik.es/v2/networks -Y --threshold-red 325

httping-color-demo

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →