简体   繁体   中英

How to How to implement pacing in JMeter using Ultimate or stepping thread group combining with while controller

I am trying to achieve pacing in my JMeter script similar to LR

LR Pacing LR Pacing

JMeter Scenario I am using the Stepping thread group with the while controller Jmeter script For pacing, I am using flow control action and a BeanShell timer Pacing details

  1. Most probably your Beanshell code fails:

    在此处输入图像描述

    take a look at jmeter.log file and see what's the reason for the failure

  2. Since JMeter 3.1 you're supposed to be using JSR223 Test Elements and Groovy language for scripting.

  3. With your LoadRunner settings you need to measure the iteration duration. So you need to record the time of the iteration start. It can be done by adding a JSR223 PreProcessor aa child of the very first request in the Thread Group (or other source of iterations) and put the following code there:

     vars.putObject('start', System.currentTimeMillis())

    then in the end of the Thread Group (or other iterations source) you need to add a JSR223 Timer with the following logic:

    • Get current time
    • Compare it with the iteration start time
    • If the iteration took 850 seconds or more - return 0
    • If the iteration took less than 850 seconds - return the delta between 850 seconds and iteration duration

    Example code:

     def start = vars.getObject('start') as long def end = System.currentTimeMillis() def iterationDuration = end - start if (iterationDuration >= 850000) { return 0 } else { return 850000 - iterationDuration }

Also be aware that in JMeter there are way more elegant options to control the number of requests like Constant Throughput Timer

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM