Go back to all articles

JMeter. Changing intensity with Constant Throughput Timer

Jul 26, 2020
2 min read

JMeter is a highly extensible, open-source platform that can help identify performance issues in your application. It is among the most popular tools for performance testing. You can read more about difference between PFLB, LoadRunner and JMeter.

So in JMeter, it is no longer possible to change the intensity, the number of threads and the duration of the test by standard methods after starting the test. However, it happens that the test is already running, but you urgently need to change a parameter (for example, I often forget to indicate the test duration), for which you need to stop the test, set database to the initial state, reboot the cluster, pull the original git commit and so on. Solution: configure and run BeanShell Server. With the help of BeanShell Server one can “play” with the following settings. Let’s illustrate it on the example of intensity change.

Variables

jmeter_loc – the full path to the root jmeter folder

host, port – jmeter’s host and port for the machine, where it is running

bsh_loc – folder, containing bsh-files

new_throughput – new intensity value, op/min

old_throughput – default intensity value, op/min

JMeter configuration and start from the command line

  • 01
    We create the file name.bsh: «setprop(“hits”,args[0]);»
  • 02
    In jmeter.properties search for: «BeanShell configuration» and comment out the lines «beanshell.server.port=9000» и «beanshell.server.file=../extras/startup.bsh».
  • 03
    After rebooting jmeter the server start line appears in the command line window:
  • 04
    Set target throughput to ${__P(hits, %old_throughput%)}.
  • 05
    If needed during the test we set the new throughput from the jmeter root folder in cmd to: «java –jar %jmeter_loc%\lib\bshclient.jar %host% %port% %bsh_loc%\name.bsh %new_throughput%».

Explanation

In the line «java –jar %jmeter_loc%\lib\bshclient.jar %host% %port% %bsh_loc%\name.bsh %new_throughput%» we call bshclient and indicate, which host and port are opened to the bsh-server, as well as which bsh-script needs a new parameter.

Example solution for a maximum search test

The project profile consisted of 20+ operation, so changing each intensity change manually is not fun. We wanted to find a maximally scalable and parametrized solution, which would allow us to use it for different projects with a different operation amount and from different loading machines.

Let’s illustrate it on the example of intensity change.

In the end we’ve written a “universal” .bat-file to change intensity,

jmeter example 1

where vals-line contains new intensity values, separated by letter “a”.

name.bsh:

jmeter example 2

In JMeter load test scenario we add a separate thread group and in it – jsr223-sampler. Constant timer is added to the thread group and the intensity change is fired by it. Base intensity values for each iteration are saved in User Defined Variables.

jmeter example user defined param

Function Helper explains, how to use intensity values syntax in Target Throughput.

jmeter example function helper

After the .bat-file has been executed, the command line stays open, so we see that the intensity values have successfully been changed.

jmeter example command

And that the command has looked like that:

java -jar C:/Users/User/Desktop/apache-jmeter-5.1.1\lib\bshclient.jar localhost 9000 C:/Users/User/Desktop/apache-jmeter-5.1.1/bsh\name.bsh 1344 2016 2016 240

We observe the intensity change in Transaction per Second:

jmeter example changing intensity

The intensity has been doubled.

Have a Project in Mind?​
We have been working on performance testing projects since 2008.
Drop us a line to find out what our team can do for you.
Get a quote You’ll hear back from our tech account manager in one day if not sooner

Conclusion

Using the described approach, you can increase and reduce intensity, thread amount and test duration, which saves time and helps to choose the optimal load options.

Table of contents

Related insights in blog articles

Explore what we’ve learned from these experiences
6 min read

Top 5 JMeter Alternatives

top jmeter alternatives preview
Dec 20, 2024

It’s hard to find someone in the performance testing community who hasn’t heard of Apache JMeter. We love it for being open-source, free, feature-rich, protocol-friendly, and easily extendable. While JMeter remains a favorite, there are other tools that offer unique strengths and advantages. This article presents a comprehensive list of the top 5 JMeter alternatives, […]

5 min read

How to Load Test API: A Full Guide

how to load test API- a full guide preview
Dec 18, 2024

In today’s digital ecosystem, APIs form the backbone of diverse software applications, facilitating communication and data exchange for an interconnected digital world. However, as demand for these services grows, ensuring their robustness and ability to handle varying levels of traffic becomes crucial. This is where PFLB, a next-generation, cloud-based load testing tool, comes in. In […]

7 min read

Top 8 Gatling Alternatives Overview

Top Gatling alternatives preview
Dec 16, 2024

Gatling Cloud, a cloud-based extension of the open-source performance testing tool, is a powerful load testing solution with its benefits. Those include excellent scalability, no-code test builder, moderate price for virtual user hours (VUh), and numerous useful integrations. However, with its steep learning curve due to reliance on Scala/Java and setup (and overall) complexity, it […]

13 min read

Top 10 BlazeMeter Alternatives

top blazemeter alternatives preview
Dec 13, 2024

Over a decade ago, BlazeMeter reshaped the landscape of load testing by moving it to the cloud. Serving as a cloud-based execution platform for the well-known JMeter, it freed engineers from the burden of managing infrastructure and allowed them to focus solely on testing. The result was a significant reduction in operational complexity and a […]

  • Be the first one to know

    We’ll send you a monthly e-mail with all the useful insights that we will have found and analyzed