Hello,
We have a tutorial on this approach, you can find it here:

   - JMeter Switch Controller or How to Run a sampler with a certain
   
Percentage<http://www.ubik-ingenierie.com/ubikwiki/index.php?title=JMeter_Switch_Controller_or_How_to_Run_a_sampler_with_a_certain_Percentage>


Regards
Philippe

On Wed, Oct 12, 2011 at 10:32 PM, Philippe Bossu <pbo...@gmail.com> wrote:

> Hello,
> Thank you very much for all your responses, I will try it.
>
>
> Regards
> Philippe
>
> On Wed, Oct 12, 2011 at 10:22 PM, sebb <seb...@gmail.com> wrote:
>
> > On 12 October 2011 20:43, David Parks <davidpark...@yahoo.com> wrote:
> > > This is as expected in this scenario, I was using it with an infinite
> > loop,
> > > so in the end the percentages are roughly correct (but still randomly
> > > distributed, which accounts for the error you are noting). But note how
> > the
> > > logic works here, each iteration it will pick one controller, and that
> > > controller may or may not run in that iteration (depending on its
> > percentage
> > > probability that it will run). This will randomly distribute load.
> > >
> > > If you want to control executions precisely and not just distribute
> load
> > in
> > > percentages then we need to consider another approach. And now I notice
> a
> > > few details of your original email that I didn't take into account.
> > >
> > > Here are a few other ideas you can play with:
> > >
> > > Random Controller
> > >  * Module Controller A [20%]
> > >  * Module Controller A [20%]
> > >  * Module Controller B [20%]
> > >  * Module Controller C [20%]
> > >  * Module Controller C [20%]
> > >
> > > In this scenario A & C will run 40% of the time and B will run 20% of
> the
> > > time, but one of them is always selected by the Random Controller. You
> > can
> > > use the module controller to allow you to define A, B, and C elsewhere
> > and
> > > duplicate their use in this sense.
> > >
> > > Another idea is the If Controller - I haven't used it so I'm just going
> > off
> > > the top of my head here, but I would experiment with creating a random
> > > variable (0-1.0) using the [Random Variable Configuration Element] to
> > > determine which IF controller to run, and each IF controller only runs
> if
> > > the random variable defined at the beginning of the loop is say: (0-0.3
> =
> > > 30%, A), (0.3-0.4 = 10%, B), etc. This would guarantee 1 and only 1 of
> > the
> > > controllers run in a probabilistic pattern.
> >
> > Or generate a number in the range 0-9, and use the switch controller
> > with 10 child samples in the appropriate percentages.
> >
> > If you convert the random number 0-9 into 0-3 in the appropriate
> > percentages, you can use just 4 samples.
> >
> > This can be done using a BSF/JSR223/BeanShell Pre-Processor to create
> > a variable in the appropriate range.
> >
> > Pseudo-code:
> > r=random[0-9]
> > n={0,1,1,1,1,2,2,2,3,3}[r] // index the array
> >
> > Switch Controller ${n}
> >
> > Or you can create a CSV file with a suitable random mix of numbers and
> > use that to define the Switch variable
> >
> > > I'll bet you could come up with a couple more ways of tackling it if
> you
> > > really tried, but hopefully these give you enough ideas to get by.
> > >
> > >
> > >
> > > -----Original Message-----
> > > From: Philippe Bossu [mailto:pbo...@gmail.com]
> > > Sent: Wednesday, October 12, 2011 11:53 AM
> > > To: JMeter Users List
> > > Subject: Re: Question about ThrouputController
> > >
> > > Hello,
> > > Thanks for this I tried it but I doesn't work .
> > > I set 1 threads running 50 LOOP Count => I get 24 executions
> > >
> > > That's not what I want, I want 50 executions with the repartition,
> > because
> > > in this case If I have a sampler waiting for RandomController run
> result,
> > > it will fail since it may not execute.
> > > is it something possible ?
> > >
> > > By the  way, percentages are not well respected.
> > > 7 / 24 => 30 % => I get 7 executions => OK
> > > 4 / 24 => 10% => I get 4 executions => KO
> > > 8/ 24 => I get 8 executions => 33% KO
> > > 5 / 24 => I get 5 executions => 20% OK
> > >
> > >
> > > Regards
> > > Philippe
> > >
> > >
> > > On Wed, Oct 12, 2011 at 7:31 PM, David Parks <davidpark...@yahoo.com>
> > wrote:
> > >
> > >> I did this as follows:
> > >>
> > >> * Thread group (define how many requests should be going through at
> one
> > >> time)
> > >>  * Random Controller (pick any of the sub controllers at random each
> > >> iteration)
> > >>    * Throughput Controller A [10%, By Percent]
> > >>    * Throughput Controller B [40%, By Percent]
> > >>    * Throughput Controller C [30%, By Percent]
> > >>    * Throughput Controller D [20%, By Percent]
> > >>
> > >> This generates randomly distributed load over Controllers A-D
> according
> > to
> > >> the percentages defined.
> > >>
> > >> I also threw in a timer at the Random Controller level to limit the
> > >> requests
> > >> to once every X seconds, this way I could define the number of threads
> > as
> > >> representative of an real-world active user.
> > >>
> > >> Hope that gives some food for thought.
> > >>
> > >>
> > >> -----Original Message-----
> > >> From: Philippe Bossu [mailto:pbo...@gmail.com]
> > >> Sent: Wednesday, October 12, 2011 10:13 AM
> > >> To: jmeter-user@jakarta.apache.org
> > >> Subject: Question about ThrouputController
> > >>
> > >> Hello,
> > >> First thank's for your help and great JMeter product.
> > >>
> > >> I have the following requirement.
> > >> I would like to execute 4 different samples at the following
> frequence:
> > >>
> > >>    - 10% for A
> > >>   - 40% for B
> > >>   - 30% for C
> > >>   - 20% for D
> > >>
> > >> A,B,C and D do search on different criterions.
> > >> At least one of them must be executed because next sampler will use
> the
> > >> search result.
> > >>
> > >>
> > >> I tried to use ThroughputCOntroller but when I ran it once, none of
> the
> > 4
> > >> is
> > >> executed.
> > >> Random Controller does not do the job.
> > >> InterleaveController as parent of TPC may be an option but I don't
> > >> understand how to use it with others
> > >> SwitchController might also be an option based on a question sebb
> > answered
> > >> to on the mailing list but how to randomize ?
> > >>
> > >>
> > >> Thank you for your help.
> > >> Regards
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: jmeter-user-unsubscr...@jakarta.apache.org
> > >> For additional commands, e-mail: jmeter-user-h...@jakarta.apache.org
> > >>
> > >>
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: jmeter-user-unsubscr...@jakarta.apache.org
> > > For additional commands, e-mail: jmeter-user-h...@jakarta.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-user-unsubscr...@jakarta.apache.org
> > For additional commands, e-mail: jmeter-user-h...@jakarta.apache.org
> >
> >
>



-- 
Cordialement.
Philippe Mouawad.
Ubik-Ingénierie

Reply via email to