Table of contents
1.
Introduction
2.
About Jmeter Timers
3.
Features of JMeter Timers
4.
JMeter Timer Workflow
5.
Types of Timers present in Jmeter-
5.1.
Constant Timer
5.2.
Uniform Random Timer 
5.3.
Precise Throughput Timer
5.4.
Constant Throughput Timer:
5.5.
BeanShell Timer 
5.6.
JSR223 Timer 
5.7.
Gaussian Random Timer 
5.8.
Poisson Random Timer 
5.9.
Synchronizing Timer 
6.
Using Timers
7.
Frequently Asked Questions
7.1.
What is Performance Testing, and why is it important?
7.2.
 Is the JMeter tool capable of simulating a real browser?
7.3.
Describe how JMeter works internally.
7.4.
What is the purpose of the Timer in JMeter?
8.
Conclusion
Last Updated: Mar 27, 2024

Introduction to JMeter Timers

Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Apache JMeter is an open-source load and performance testing software that is purely based on Java Language. JMeter was developed by Stefano Mazzocchi of the Apache Software Foundation. It was primarily written to load and test the performance of Apache JServ (also called the Apache Tomcat project). Later on, to add more features and functional testing capabilities, the Apache community redesigned it to enhance the GUI. Its functionalities have grown to include testing web pages, web apps, and other static and dynamic resources like databases, LDAP, Java objects, rest web services, and more. 

Introduction to JMeter Timers

The timers help us to generate real-life experience traffic. Suppose there are thousands of users hitting the website. First of all, not all the users are hitting the website at the same time, and second thing, not all the users have the same way of exploring the website. There will be some time gap in each and every action taken by the users. So to generate real traffic, Jmeter has provided us with some timers. 

Let's now explore these JMeter timers.

About Jmeter Timers

The primary objective of using timers is to simulate the "think time" of a virtual user. The term "think time" in the context of load testing refers to the simulation of real user behavior that results in a pause between user engagements with a web application.

Jmeter Image

Testing without a JMeter timer can give inaccurate test results because the simulated requests will be in a different pattern than what we get in the real-world scenario.

Jmeter is a very handy tool. It does not require extensive programming knowledge. Only prior knowledge of Java language is preferred. To install Jmeter, run JMeter.bat on windows and Jmeter.sh on Linux.

Features of JMeter Timers

The main features of JMeter include:

  • License: JMeter is open source and platform-independent, supports all environments, and is readily available.
  • Graphical User Interface: Compared to other performance testing tools, Jmeter timers are simple, free of cost, user-friendly, and easy to learn.
  • Server/ Protocol Support: JMeter can test different servers, apps, and protocols for load and performance. A few protocols include the following -
Server/ Protocol Support
  • Test Result Visualisation: Test results can be viewed in different formats-
Test results img
  • Simulation: Simulate multiple users using virtual or unique users to generate heavy traffic on web servers or services.
  • Reporting: JMeter only offers XML and CVS Report Formats by default. We can combine Jmeter with ANT to create an HTML report per our requirements.
  • Testing Types: Jmeter is effective for functional, regression, and soak/endurance testing in addition to performance, load, and stress testing.

Let’s now understand the workflow of Jmeter Timers.

JMeter Timer Workflow

JMeter Timer Workflow

Now that you might be wondering how the JMeter timer actually works? Let's understand the concept in brief. A large number of users are simulated by JMeter while sending a requests to the AUT(Application Under Test). When JMeter simulates requests, the server responds, and Jmeter starts collecting data. 

Jmeter records every response and provides statistics based on the server response. Thus, in order to implement real-world scenarios, we can use JMeter, to simulate the demand on the servers, networks, or objects originating from various machines.

Types of Timers present in Jmeter-

There are total nine types of JMeter timers available. Each timer has its own usability. Some of the timers are discussed below-

Types of Timers present in Jmeter

Some of the timers are discussed below-

Constant Timer

The Constant Timer will add some delay to the threads before they are initiated. This thread delay is a constant in milliseconds. Hence, this timer is used to add some 'think time'(or delay) between each user request. 

Constant Timer

Uniform Random Timer 

Uniform random timer is used to add a random amount of delay or think time between the user requests so that each request has a unique timing. The total delay in the uniform random timer is the sum of the random delay value and the constant delay offset value.

Uniform Random Timer

Precise Throughput Timer

In the precise throughput timers, the user sets a target # of requests per minute/second(number of samples per throughput period).

Precise Throughput Timer

Constant Throughput Timer:

The Constant Throughput Timer is similar to the Precise Throughput Timer, except that it offers fewer settings. Essentially, it strictly sticks with a target throughput, and does not allow the flexible variance of the Precise Throughput Timer.

Constant Throughput Timer:

BeanShell Timer 

In the BeanShell Timer we can develop the logic of how to implement a timer. It can be used to generate a delay time between every user requests.

BeanShell Timer

JSR223 Timer 

JSR223 Timer is a scripting-based timer that creates a delay between each user request. 

JSR223 Timer

Gaussian Random Timer 

Gaussian random timer delays each user request for a random period of time. It has a random deviation around the Constant Delay Offset based on Gaussian curve distribution.

Gaussian Random Timer

Here the value of total delay time will be the sum of return value of Gaussian distribution function and constant delay offset(Additional value in milliseconds). 

Poisson Random Timer 

Poisson Random timer has almost the same functionalities as a Gaussian Random timer. It offers a delay time between the requests for a random interval of time. The sum of Lambda (in milliseconds) and Constant Delay offset represents the total delay in time.

Poisson Random Timer

Synchronizing Timer 

The Synchronizing Timer in JMeter holds the threads until X number of threads arrive, and then they are all released at once.  Introducing delays between requests prevents all (specified) threads from firing at once, thus creating heavy load bursts on the application. Hence the Synchronizing Timer pauses all the threads in its scope unless their number won't be equal or greater than the number, specified in “Number of Simulated Users to Group by” input.

Synchronizing Timer

Using Timers

Now that we know that timers can be used to set a fixed or a random delay between each user requests. Let us consider an example of an employee who is overloaded with the task of performance testing of www.google.com for 100 users. That seems like a herculean task. Isn’t it? But don’t worry JMeter Timers is there for the employee’s rescue!

Using the JMeter Timers, employee can add a constant timer and add view results in a table. After that he can simply run his test and get the desired result. Still unclear? Keep calm and follow these steps-

  • Step 1 : Open the JMeter window by clicking-
Apache JMeter Path Directory

Once you click on the batch file, Apache JMeter screen will appear as this:

Apache JMeter window
  • Step 2: Now right click on the Test Plans and follow these steps-
adding thread group

Now enter the thread properties so that JMeter can create one user request to http://www.google.com for 100 times.

Thread properties
  • Step 3: Now add the Jmeter sampler as per your requirement. 
Adding requests
  • Step 4: The next step is to add the timer. Here you can use the constant timer. To add the timer follow the given steps-
adding timer

Configure the thread delay of 4000ms.

Configure the thread
  • Step 5: Now add the ‘View Results in Table’ to displays the test result in table form by following the given steps-
Adding test format
  • Step 6: After adding the required output format, save the file and click the ‘Run’ button on the menu bar. Your out should be somewhat similar to this-
View result in table format

Where the delay of every sample is equal to the value you have assigned to the thread delay while adding the timer. 
By following similar steps, you can use other timers for different use cases. Now it’s time for some frequently asked question.

Must Read Apache Server

Frequently Asked Questions

What is Performance Testing, and why is it important?

Performance testing is non-functional testing that evaluates the application's performance under expected or higher loads. It's done before the app goes live to ensure it doesn't crash and replies in a reasonable amount of time under real-world conditions.

 Is the JMeter tool capable of simulating a real browser?

No, JMeter does not replicate or operate the same way as a genuine browser. It cannot render HTML responses as a real browser can.

Describe how JMeter works internally.

JMeter creates numerous threads that make simultaneous requests to a target server to simulate real-world user load. The server's performance is then displayed via tables and graphs.

What is the purpose of the Timer in JMeter?

JMeter can use a timer to delay the time between each request a thread makes. It is capable of resolving the server's overload issue.

Conclusion

JMeter timers are simple, yet it is very powerful tool. You can create excellent load tests with the proper knowledge of the timers functionality. This article is all about JMeter timers and its types.

To explore more on JMeter Timers, here are more articles for rescue. 

Refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, JavaScript, System Design, etc. Enroll in our courses and refer to the mock test and problems available. Take a look at the interview experiences and interview bundle for placement preparations.

Happy Learning!

Live masterclass