JMeter override timers / reduce timer for certain step in larger scope

Viewed 26

I am running a JMeter scenario which has a certain think time applied for the entire scenario.

During one small loop in this scenario, I wish to decrease the think time between each sampler. E.g., if the default scenario think time, for all samplers, is 500ms, I wish to make this one small loop have a think time of only 100ms.

It does not seem like this is possible, but I also don't see any other questions asking this. Does anyone know of a workaround to accomplish what I am trying for?

This line in the JMeter docs suggests that this is not possible:

Note that timers are processed before each sampler in the scope in which they are found; if there are several timers in the same scope, all the timers will be processed before each sampler.

https://jmeter.apache.org/usermanual/component_reference.html#timers

1 Answers

You can do the following:

  1. Declare a JMeter Variable to hold the default think time somewhere in User Defined Variables

    enter image description here

  2. In all Constant Timers (or in the one if it's applied to all the Samplers) set it to use the JMeter Variable from the step 1:

    enter image description here

  3. Before entering your "small loop" add a JSR223 PostProcessor to the last Sampler and put the following code into "Script" area:

    vars.put('think-time', '100')
    

    enter image description here

    In the above code vars stands for JMeterVariables class instance, see Top 8 JMeter Java Classes You Should Be Using with Groovy article for more information if needed.

  4. Before exiting the "small-loop" do the reverse thing and restore the original value of the think time

    enter image description here

Related