FYI, also got feedback in another JMeter forum: http://www.sqaforums.com/forums/jmeter/155871-weighted-frequency-random-execution-samplers-test-plan-similar-locus.html
that pointed me to https://jmeter-plugins.org/wiki/WeightedSwitchController/ On Sat, Jul 29, 2017 at 6:12 PM, David Luu <[email protected]> wrote: > Thanks for the suggestion. And I look forward to seeing the PR in a future > release. > > On Sat, Jul 29, 2017 at 7:52 AM, Felix Schumacher <felix.schumacher@ > internetallee.de> wrote: > >> >> >> Am 29. Juli 2017 16:49:21 MESZ schrieb Philippe Mouawad < >> [email protected]>: >> >Hello, >> >Note there is a PR for >> >https://bz.apache.org/bugzilla/show_bug.cgi?id=60274: >> > >> > - https://github.com/apache/jmeter/pull/233 >> >> So we should look at that pr again after the current release. >> >> Felix >> >> > >> >Regards >> > >> > >> > >> >On Sat, Jul 29, 2017 at 4:44 PM, Felix Schumacher < >> >[email protected]> 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: [email protected] >> >> For additional commands, e-mail: [email protected] >> >> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> >
