Weighted random values?

How can I run random weight tests / controllers? For example, you have two tests: one with a mass of 25%, the other with 50%. Anyone with 50 should work twice as often.

Maybe a bandwidth controller mixed in randomly?

+4
source share
4 answers

I think you can use the bandwidth controllers configured as shown below:

Throughput controller

The throughput values ​​are predefined either from the configuration properties or are generated in an acceptable range of values ​​(in this case 0.00).

+5
source

For some simple scales, you can use the fact that the switch controller by default uses the first child to your advantage. For example, 50% 25% 25% like

Switch Controller - ${__Random(0,3)} - Child 0 (and 3) - Child 1 - Child 2 

You take this one step further by grouping tasks into Random and Simple controllers as children.

+1
source

For this case, it is better to use 2 groups of threads. First configure to generate more queries than the second.

PS. You can use Time Shaping Timer to control the speed in each group.

0
source

I achieved this by creating a switch controller with the following switch value:

 ${__javaScript( var s="001"; new Number(s.charAt( Math.floor(Math.random()*s.length) )) )} 

javascript selects a random character from string s and converts it to a number. Thus, in the above example, 0 will be selected twice as often as 1, and the scales can be changed by adding / removing characters from the string.

I used String, not an array, because the javascript version used by my version of JMeter did not seem to support array literals, so this made it a little less verbose.

0
source

Source: https://habr.com/ru/post/1345816/


All Articles