jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philippe Mouawad <philippe.moua...@gmail.com>
Subject Re: Weighted (frequency of) random execution of samplers in a test plan? Similar to locust.io option
Date Sat, 29 Jul 2017 14:49:21 GMT
Hello,
Note there is a PR for https://bz.apache.org/bugzilla/show_bug.cgi?id=60274:

   - https://github.com/apache/jmeter/pull/233

Regards



On Sat, Jul 29, 2017 at 4:44 PM, Felix Schumacher <
felix.schumacher@internetallee.de> wrote:

> Am 27.07.2017 um 03:35 schrieb David Luu:
>
>> JMeter has random controller, and I was wondering how one would set up
>> weighted ratios of different samplers executing at different frequency in
>> the random draw.
>>
>> For example comparing to the option available in locust.io by specifying
>> the ratio of execution frequency:
>>
>> http://docs.locust.io/en/latest/writing-a-locustfile.html#declaring-tasks
>> http://docs.locust.io/en/latest/writing-a-locustfile.html#tasks-attribute
>>
>> What is the equivalent for JMeter, if available?
>>
>> Would it be nesting random controllers so the the less frequent samplers
>> go
>> into yet another random controller within a root random controller and
>> continue the nesting process for the lesser frequent samplers and the
>> highest weighted one is under root random controller?
>>
> I would use a switch controller together with some jsr223 scripting. You
> could use:
>  - test action
>    - jsr223 preprocessor (for code see below)
>  - switch controller (switching on ${switchValue} which is set in
> preprocessor above)
>    - simple controller (named with one of the possible values of
> ${switchValue} see below)
>    - simple controller (..)
>    ...
>
> Code for the preprocessor:
> ---start snippet---
> weightsMap = ["first": 5, "second": 3, "third": 1]
>
> def computeSwitchValue(weightsMap) {
>     weightsSum = weightsMap.values().sum()
>     r = Math.random() * weightsSum
>     sum = 0.0
>     for (entry in weightsMap.entrySet()) {
>         switchValue = entry.key
>         sum += entry.value
>         if (sum >= r) {
>             return switchValue
>         }
>     }
> }
>
> vars.put("switchValue", computeSwitchValue(weightsMap))
> ---end snippet---
>
> Don't forget to check "Cache compiled script if available"
>
> The weights are defined in weightsMap where the keys are the names of the
> controllers inside the switch controller and the values are the actual
> weights.
>
> Hope this helps,
>  Felix
>
>>
>> Thanks,
>> David
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>


-- 
Cordialement.
Philippe Mouawad.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message