Timers are one of the simplest, yet most powerful tools in the range of any JMeter user. There are many types of timers available to meet the various scenarios you may be trying to simulate with JMeter.
In this article, we will cover the main types of timers that are available on the market, and provide examples of when and how to use these timers to improve your testing.
A JMeter Timer is a built-in plugin tool for JMeter that can help with spacing out your sample requests.
Many testers call this gap in requests to think time, simulating the time that real users spend in between each step they perform in a real-world scenario.
By default, each request in JMeter is made immediately after the other. With a JMeter timer, users can use a static or variable time to separate requests.
For example : you may be interested in ensuring every single user can execute a specific number of requests per second so that you can hit a target minute, hourly, or daily transaction count.
In this case - we might want to test an API with 200 requests per second using 100 users. We would use a timer so that each user sends a request every 500 milliseconds. This will achieve the 200 requests per second target as long as the response time is less than 500ms.
There are 9 different types of built-in Timers are available in JMeter :
To help you understand how to use a JMeter Timer, we have created a repository with an example script including a basic timer. In this example, we have added a Gaussian random timer that will be added before kicking off any recorded thread group.
This is quite a basic example, there are many more complex ways to implement a JMeter Timer. Like any other element in a test plan, a JMeter Timer has a scope which will determine which samplers are impacted by the timer.
Make sure that if a timer is meant to only be applied to a single sampler, that it is added as a child element of the sampler as shown, to restrict the scope to only that sampler.
It is also worth noting that Timers will always be executed before any sampler that is in scope. Additionally, multiple timers will be run consecutively meaning all of the timers in scope will be executed before the sampler.