Add delay to JMeter Dummy Sampler

  • I'm looking into the BlazeMeter Advanced JMeter tutorial (

    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) {"Iteration Count: ${iterationCount}")
        long delayVal = Long.parseLong(props.get("delayProp"));
        if (delayVal < 400) {
            delayVal = delayVal + 1
            props.put("delayProp", String.valueOf(delayVal))
  "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

  • 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.

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2