Compared to the loadrunner,jmeter in the complex scene approach seems to be slightly deficient. Some time ago, want to implement a function, if there are two sampler A and the B,a sampler and the B sampler is executed by the probability of 1/4 and 3/4, then how should be implemented?
Find the information on the Internet, found that most of the online is three kinds of practices:
1. Multithreading, such as a sampler with 20 threads, b thread with 60 threads, so the proportion is 1:3
However, this will create a problem, if performed by the time dimension, the execution of the 10min,a sampler and the B sampler response time is not the same, then the number of requests A and B during this period can not be 1:3
2.jmeter comes with a calculation function that can be used to achieve the effect.
Briefly describe the function of the controller, which counts each request, which is equivalent to giving him a number.
When the parameter is true, each user has its own counter, such as 10 thread groups, 100 loops, which is the counter value of 1-100.
When selected false, Global calculator, 10 thread group, 100 loops, counter value 1-10000
Then if you want to use a scale of 1:3, use an If controller.
Conditions are ${__counter (true,)}%4==0 with ${__counter (true,)}%4!=0
See http://blog.csdn.net/selingchen/article/details/47844375
3. Using JSR223 Sampler + Groovy
Add the following code to the controller
Int[] values = (int[]) vars.getobject ("Random_values"), if (values==null) { values = [0,1,2,3,2,3,1,3,2,3] As Int[]; Vars.putobject ("Random_values", VALUES);} Increment that'll be used in switchcontroller value would be between 0 and 2//because there is 3 Tcsinteger incremen t = (Integer) vars.getobject ("INCREMENT"), if (increment==null) { INCREMENT = integer.valueof (0);} else { Increment = Integer.valueof ((Increment.intvalue () +1)%values.length); } String value = integer.tostring (Values[increment.intvalue ())), Vars.put ("Switch_value", Value), Vars.putobject (" INCREMENT ", INCREMENT); Sampleresult.setresponsedata ("Switch_value from Inside:" +value, null); return "Switch_value:" +value;
The equivalent of each time in the Random_values array traversal, take the value inside, and then use if controller to determine the effect of achieving percent.
See: HTTP://WWW.OSCHINA.NET/TRANSLATE/JMETER-CONTROL-PERCENTAGE-OF-SAMPLER?CMP
For the above three ways to compare:
The programme, needless to say, sometimes does not achieve the effect of a percentage distribution request.
Program three has been tested, there is a big drawback, using a sampler, the consumption is larger. In particular, there are more complex scenarios, such as a A-B two scenarios, a JSR223 sampler is required, a scene below a composite scene, the need to scale distribution requests (this is quite common), then need to add a sampler. In this case, it is too cumbersome, if the use of local jmeter, not distributed, it may be because the cost is too big to cause stress.
Scenario Two: It is a good idea to use a calculator that comes with JMeter itself. But for some complex scenarios, this formula is a bit hard to write,
For example: 3:2 This ratio, I see the implementation of the Internet is ${__counter (true,)}%2==1| | ${__counter (True,)}%3==0,
This method of calculation is more complicated, is there a simple way to achieve it?
Actually, there is.
For example, the following scenario:
Jmter how to implement percent run controller