//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;
}
1条答案
按热度按时间ni65a41a1#
1.如果没有定时器,您将无法实现调步,因为您需要添加延迟和the relevant test element for introducing a delay is a timer.
1.如果您想使用脚本引入调步,请注意,从JMeter 3.1开始,建议使用JSR223测试元素和Groovy语言,因此显而易见的选择是JSR223计时器
示例代码: