Timers in JMeter with Examples

In this JMeter Tutorial, you will learn about Timers in JMeter. Many times it happens that there is requirement of delay of sometime interval, between the requests to be executed.

Suppose you are entering your user credentials on any website and submitting it, then you have to wait for some time, say, 4 to 5 seconds, for welcome page to appear so that you can perform any action on the welcome page, which appears just after login, so that delay which is required between the execution of samplers or requests is accomplished by Timer in the JMeter.

Suppose we have request/sampler A and wehave another request/sampler B and there is requirement that there should be delay of five seconds after request /sampler A is executed and after execution of request /sampler A is complete, JMeter needs to wait for five seconds before  executing sampler/request B. For handling such scenarios, we need to use Timer in JMeter. We need to add Timer under thread group.

Constant Timer

Constant timer element in JMeter is used to create delay between requests/samplers for the specified amount of time. We can configure delay time while configuring Constant timer in JMeter.

If we set delay of 3000 ms, then, JMeter will wait for 3000 milliseconds to process next sampler/ request. Let us see how we will add timer in JMeter. First, we will create Thread Group under Test Plan , then we will right click on Thread Group then we will select add >> Timer and in Timer will select Constant Timer.

Timers in JMeter - Constant Timer

Now, after we select constant time are timer, we will see a window where we have option to configure delay time which we can see in the screenshot given below.

Timers in JMeter - Constant Timer 2

In the screen shot given above, we can clearly see that we have configured the great delay of 300 million seconds, which means that next request thread/sampler will be executed only after 300 ms.

Uniform Random Timer

Are the name itself is telling, Uniform Random Timer is used to set random time delay between the samplers/requests. We can see in the screenshot below that we need to set Thread Delay Properties, which contains two fields, one is used for setting on constant delay and other is used for setting random delay.

We can see that there is constant delay set to 7000 ms and random delay had been set to 3000 ms. , It means that there will be random delay between 7seconds to 10 seconds.

Timers in JMeter - Uniform Random Timer

Gaussian Random Timer

This primary is also used to force delay for random period of time. The only difference is that it is based on Gaussian distribution. We will set the value in same way, which we did for uniform render random timer.

However, the algorithm used will be different. Only thing we need to understand here is that deviation is based on Gaussian formula and based on that random number is generated, which generates random delay for an executions between samplers/requests.

Main thing to understand is that we get random delay which we actually do not know. This random delay is based on the number which is generated based on the input given in Thread Delay Properties while configuring Gaussian Random Timer, as shown in the screenshot below.

Timers in JMeter - Gaussian Random Timer

Bean Shell Timer

This element forces delay between user requests based on Bean shell scripting conditions. After the Bean Shell scripting condition is satisfied, JMeter begin execution of next request.

We can say that it is script-based timer. Advantage of using this timer is that we can define think time based on the condition given in Bean shell script. We can keep JMeter waiting for some time, until the condition given in Bean shell scripting is satisfied.

Only after the condition given in the Bean shell scripting is satisfied, execution of next sampler/ request starts.

We can clearly see in the screenshot given below that there is Script field where we need to and until the condition in this script is satisfied, JMeter does not allow execution of next thread request.

It is not so commonly used but it is very powerful Timer used because it gives power to create a customized delay.

Timers in JMeter - Bean Shell Timer

BSF Timer

BSF timer work in the same manner as Bean shell timer. Only the difference is that it BSF scripting language.

Script condition is written in same way. Here also, we need to get the condition written in the script, satisfied so that next request sampler could be executed.

Timers in JMeter - BSF Timer

JSR223 Timer

It also works in same way as BSF timer was working.

The only difference is that it also uses one scripting languages to create delay between execution of samplers/requests. The name of the scripting language is JSR223. Here also condescended to be certified.

Timers in JMeter - JSR223 Timer

Synchronizing Timer

Let us consider a scenario to understand it in a better way. Let us suppose that we have a scenario which contains three actions.

First action is login to the application, second action is to click on a link that is appearing on the page and third action is to log out of the application. Now we want this scenario to be executed by 100 users/ threads.

Now let us consider special scenario where we want that all hundred users/ threads click on the link given on second page simultaneously which is second action. In other words, we can say that we have requirement that all hundred users start executing second action simultaneously.

Now comes Synchronizing timer in picture. It stops all threads after execution of first action to a point until all the threads arrive and is ready to work on 2nd action simultaneously.

Professionals who have worked on LoadRunner should know that it is same like Rendezvous Point in LoadRunner.

We have covered most frequently used Timers in JMeter. There are many other timers available as well in JMeter.

They all work in almost same manner with little difference in their working style and some use different scripting language.

But the main thing to understand is that Timer plays very important role when it comes to simulate real-time environment in performance testing.