I'm looking into the BlazeMeter Advanced JMeter tutorial (https://academy.blazemeter.com/courses/advanced-jmeter/)

In lesson 7: Pacing, he uses some Groovy code to delay the dummy sampler, which is as follows:

long iterationCount = ${__counter(FALSE,)}
if (iterationCount < 500) {
    log.info("Iteration Count: ${iterationCount}")
    long delayVal = Long.parseLong(props.get("delayProp"));
    if (delayVal < 400) {
        delayVal = delayVal + 1
        props.put("delayProp", String.valueOf(delayVal))
        log.info("Thread: ${__threadNum} Iteration: ${__iterationNum} Delay value: ${__P(delayProp,)}")

Unfortunately he doesn't show how to integrate this code in the JSR223 PostProcessor with the dummy sampler. So my sampler is not delaying when the iteration count goes over 500. Any idea on how I can apply this code for a delay in the sampler?

In the project he has following elements:

  • User Defined Variables
  • Arrival Threads Group with 3 Dummy Samplers
  • Under the 3rd dummy sampler, there is a JSR223 PostProcessor with the code
  • Response Times Over Time listener
  • Active Threads Over Time listener
  • Transactions per Second listener

2 Answers 2


I believe you should use JSR223 Timer with the following code:

//Sets the pacing length based on the last requests response time. 4500 is the time in ms
Long pacing = 4500 - prev.getTime();

//If the response time is less than 4500 ms, set the delay value to myDelay
if (pacing > 0) {
    //iPacing is equal to the int value of pacing if pacing is not equal to null, otherwise iPacing is null
    Integer iPacing = pacing != null ? pacing.intValue() : null;
    vars.put("myDelay", String.valueOf(iPacing));
    return iPacing;
//The response time is greater than or equal to 4500 ms, set myDelay to 0
else {
    vars.put("myDelay", "0");
    return 0;

Check out How to Easily Implement Pacing in JMeter article for more details.


If I recall correctly, this technique was used in the class to demonstrate a limitation of a close model, where the number of threads is fixed causing the Throughput to drop when the Response Time increases (simulated by increasing the delayPro value)

This is the way I got it working:

  1. Create setUp TG

  2. Add JSR223 Sampler to initialize the delayPro using this groovy expression:

    props.put('delayProp', String.valueOf(150)) // initial value 150ms

  3. Configure the Dummy Sampler Response Time field with the following expression:


NOTE: not certain, but I think the __iterationNum has been deprecated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.