In JMeter script, Constant Timer is used to add a constant delay before processing a sampler. If it is added at Test Plan level then it acts as a global timer and the delay is added for all the samplers before the process. If it is added under a sampler then the parent sampler will wait for the defined time and then start execution.
Refer the above screenshot, the constant timer has a delay of 1000 milliseconds (= 1 second) which will apply to all 5 requests and the execution flow will be like this:
Thread Group -> Transaction Controller -> Constant Timer -> Request 01 -> Constant Timer -> Request 02 -> Constant Timer -> Request 03 -> Constant Timer -> Request 04 -> Constant Timer -> Request 05
How to add ‘Constant Timer’ in JMeter script?
Follow the below steps to add the constant timer in the script:
- Select the appropriate element where you want to add the timer
- Test Plan
- Thread Group
- Right-click on the element
- Hover the mouse on ‘Add’
- Hover the mouse on ‘Timers’
- Click ‘Constant Timer’
What are the input fields of ‘Constant Timer’?
JMeter – Constant Timer has the following input fields:
- Name: To provide the name of the timer
- Comments: To provide arbitrary comments (if any)
- Thread Delay (in milliseconds): The pause time in milliseconds. Thread(s) will hold the execution of the sampler/request for the defined time and once the delay time is over then the sampler will be executed.
- The constant timer is processed before each sampler in the scope in which it is found; if there are several timers in the same scope, all the timers will be processed before each sampler.
- Timers are only processed in conjunction with a sampler. A timer which is not in the same scope as a sampler will not be processed at all.
- To apply a timer to a single sampler, add the timer as a child element of the sampler.
- To apply a timer after a sampler, add the Constant Timer as a child element of the next sampler.
- Flow Control Action can also be used as a timer which adds a delay between two requests.