Apply random Pacing in Jmeter Without Timers

Viewed 40

I have 10 samplers which i have to apply a pacing of 120 to 180 Seconds . I know that i can use Throughput Timers to Implement this but i wanted to know how to implement it without using timers . I guess we can use Beanshell scripting for this . But iam not quite sure on how to implement. Thankyou .

1 Answers
  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;
    log.info(String.valueOf(iPacing));
    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;
}
Related