Measure Response Time with Curl

Measure Response Time with Curl

The performance of web applications and APIs plays an important role in user experience and satisfaction. One key metric for assessing this performance is response time - the duration it takes for a server to respond to a client request. Measuring response time is essential for identifying performance bottlenecks, optimizing server configurations, and ensuring that applications meet user expectations. This tutorial explains how to measure response time with a Curl.

The simplest way to measure the response time of a URL using Curl is with the -w (write-out) option. This option allows you to specify custom information to be written to standard output after a request is completed. To get the total time taken for a request, you can use the time_total variable.

curl -w "%{time_total}s" -o NUL -s https://httpbin.org/get
curl -w "%{time_total}s" -o /dev/null -s https://httpbin.org/get

The -o option is used to discard output, since we are only interested in the timing. The -s option makes Curl silent, so it does not show progress information.

Output example:

0.448021s

Leave a Comment

Cancel reply

Your email address will not be published.