I have Test Plan which include Thread Group, in Thread Group nested 2 samplers: 1 - Dummy Sampler, 2 - JSR223 Sampler.
In Test Plan I declarated variable pacing_seconds with value - 15. In thread group the loop value is 20. I need to write groovy script in JSR223 Sampler, which should give me the result 4/min.
I'm new to this, I really need help
The easier way of limiting your Dummy Sampler to 4 requests/minute is using Constant Throughput Timer or Precise Throughput Timer or Throughput Shaping Timer , choose one depending on your future requirements.
If you want the equivalent of LoadRunner's Pacing all you need to do in Groovy is:
ctx.getPreviousResult().getTime()
function where ctx
stands for JMeterContext )pacing_seconds
variableExample code:
def pacing = ((vars.get('pacing_seconds') as int) * 1000) - ctx.getPreviousResult().getTime()
if (pacing > 0) {
def iPacing = pacing != null ? pacing.intValue() : null
log.info('About to sleep for ' + iPacing)
Thread.sleep(iPacing)
}
More information: How to Easily Implement Pacing in JMeter
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.