I wanted to apply Pacing in jmeter for 120- 180 Seconds for all my samplers , I know i can do it with Through put Timers is there anyother way to apply pacing , i think we can use Beanshell Scripting but not sure of how to implement that .

This is the sample Beanshell that i reffered from internet a i tried , i used the random function to get a random pacing beetween 120 to 180 seconds and subracting it with Previous sample time . I think this implementation is wrong . could some of you suggest on this please . Thankyou .

Long pacing =${__Random(120000,180000)} - prev.getTime();

if (pacing > 0) { Integer iPacing = pacing != null ? pacing.intValue() : null; log.info(String.valueOf(iPacing));
vars.put("mydelay", String.valueOf(iPacing)); return iPacing; } else { vars.put("mydelay", "0"); return 0; }

1 Answer 1

  1. You won't be able to implement pacing without Timers because you need to add a delay and the relevant test element for introducing a delay is a timer.
  2. If you want to introduce pacing using scripting be aware that starting from JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language so the obvious choice would be JSR223 Timer

Example code:

//Sets the pacing to be between 120 and 180 seconds
Long Pacing = org.apache.commons.lang3.RandomUtils.nextLong(120000, 180000)

//If the response time is less than the pacing 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
    vars.put("myDelay", "0");
    return 0;

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.