terça-feira, 29 de abril de 2014

How to Ramp-up threads in a specific sampler using JMeter

Apache JMeter has a Ramp-up configuration in Thread Group component.



But, what should you do if you have to ramp-up in a specific sampler?

One of the approaches I like to use is including a Javascript function in a Constant Timer.

The expression ${__javaScript(${__threadNum()}*1000)} will delay every thread by 1 second (1000 milliseconds).


Be aware that when executing this script in a distributed environment, the function ${__threadNum()} will return the same consecutive numbers (1, 2, 3, ...) for each JMeter Slave/Server used. That's because there is a "Thread 1" (or "Thread 2", "Thread 3", and so on) for each JMeter Slave/Server.

In this example I added a Synchronizing Timer and a View Results Tree to better understand the effects of this approach.



JMeter script (version 2.11) used in this post can be found here.