To simulate the real-world behaviour of threads (or virtual users), there are many elements in JMeter and the timer is one of them. While browsing a typical website, a real user always clicks, waits, reads and then provides input. In performance testing terms, the time spent by the user on the web page before providing any input is called ‘Think Time’. ‘Think Time’ stands for simulating real user behaviour which causes people to wait between interactions with a web application. To get more details on Think Time refer to the article Think Time in Performance Testing.
In JMeter, the ‘Timer’ element simulates the real user behaviour of taking a pause on a webpage. The purpose of the ‘Timer’ element is to pause a JMeter Thread for a certain amount of time. In some cases, the Timer is used to implement the Pacing.
Scope of JMeter Timer:
1. Global Timer Scope: When a timer is added to a test plan then pause (think) time is applied to all the thread groups (including individual sampler) under that test plan.
Execution Flow:
2. Thread Group Level Timer Scope: When a timer is added to a thread group level then pause (think) time is applied to all the samplers under the same thread group.
Execution Flow:
3. Parental Level Timer Scope: When a timer is added to a parent controller then pause (think) time is applied to all the samplers under the parent controller as well as the child controller (including individual samplers under the child controller).
Execution Flow:
4. Child Level Timer Scope: When a timer is added to a child controller then pause (think) time is applied to only those samplers which are under the same child controller.
Execution Flow:
5. Sampler Level Timer Scope: When a timer is added to a sampler then pause (think) time is applied to only that particular sampler.
Execution Flow:
6. Multi-Level Timer Scope: When multiple timers are added to a test plan at a different level then pause (think) time for that sampler will be equal to the sum of all timers.
Execution Flow:
Some important points related to Timer:
- The Timer is executed before the sampler’s execution but after the pre-processor.
- The parent timer is applicable to all siblings and child elements under one parent element.
- If there are multiple timers added at the above level then the think time for a sampler will be equal to the sum of all timers.
- The response time of the sampler does not include the execution time of the Timer.
The available JMeter Timer elements are:
- Bean Shell Timer
- Constant Throughput Timer
- Constant Timer
- Gaussian Random Timer
- JSR223 Timer
- Poisson Random Timer
- Synchronizing Timer
- Uniform Random Timer
- Precise Throughput Timer
Possible Parent element(s):
- Test Plan
- Thread Group
- Test Fragment
- Sampler
- Logic Controller
- Non-Test Element
Possible Child Element(s):
- NA
You may be interested:
- Performance Testing Tutorial
- Performance Engineering Tutorial
- Micro Focus LoadRunner Tutorial
- NeoLoad Tutorial