Performance testing is a crucial part of software development. It helps reveal bottlenecks and bugs and ensures our applications are responsive. One particularly important aspect is the time a web application needs to load and react to user interactions.
In this article, we're going to explore two metrics that can help detect and improve load time issues: latency and load time. We'll learn how these metrics are defined, what distinguishes them from each other, and how to measure them with the performance tool JMeter.
2. Latency and Load Time Metrics in JMeter
In JMeter, latency and load time are both metrics that measure roundtrips. In other words, they both measure the time from when a client sends a request to a server until it receives the response. However, there's an important difference between these two.
Latency is defined as the time from just before sending the request to just after receiving the first part of the response, whereas load time is the time from just before sending the request to just after receiving the last part of the response.
For both metrics, JMeter includes the time it takes to assemble the request. Latency also includes the time it takes to assemble the first part of the response, and load time includes the time to assemble the entire response. Assembling does not include the rendering of the response or any client-side code execution.
3. How to Measure Latency and Load Time
We can measure latency and load time in JMeter by creating a test plan that sends an HTTP request and uses a View Results Tree Listener.
We'll start with a test plan that JMeter automatically creates when we open the tool. In our case, let's rename it to LatencyVsLoadTime:
Next, let's create a Thread Group, which is the beginning point of every test plan. This is done by right-clicking the test plan and then selecting Add -> Thread (Users) -> Thread Group:
Next, let's add an HTTP Request by right-clicking the Thread Group and selecting Add -> Sampler -> HTTP Request:
Last but not least, we need a Listener that tracks the results of our request. Let's add it by right-clicking the Thread Group and selecting Add -> Listener -> View Results Tree:
Now that we have all parts of the test plan in place, let's configure our HTTP request.
To do this, we select the HTTP Request and set the Path to the URL we want to test. For our example, let's choose https://www.google.com:
After saving the test plan by clicking the disk icon in the top bar, we can execute it. Let's select the HTTP Request and click the play button in the top bar:
Finally, let's check the results by selecting the View Results Tree element under the Sampler result tab. In our example, the request has a latency of 215 ms and a load time of 218 ms:
In this article, we've discussed two performance metrics, latency and load time, that can help to detect load time issues and improve the usability of an application.
First, we defined the metrics in the context of JMeter and elaborated on the difference between the two. Then, we saw how to set up a JMeter test plan with an HTTP request that we could use to measure the metrics. Finally, we learned how to execute the test plan and examine the results.
The JMeter test plan that we created throughout this article is available over on GitHub.
res – Junit (guide) (cat=Testing)