On 07/07/2008, Andrey Beznogov <[EMAIL PROTECTED]> wrote: > Hi, > > that worked for sure - thanks for your advice! I guess Ill be using > BeanShellSampler and Processors a lot in my tests. > > In my case (3 options in the Switch Controller) I just had to add a > simple BeanShell Sampler just before the Switch Controller with some > very simple Java code >
> Random generator = new Random(); > double myRandom = generator.nextDouble(); > if (myRandom < 0.9) { > vars.put("REPORT_SWITCH","0"); > } else if (myRandom < 0.95) { > vars.put("REPORT_SWITCH","1"); > } else { > vars.put("REPORT_SWITCH","2"); > } > > and then use the ${REPORT_SWITCH} in the following Switch Controller. For a short script like this it might be better to use a function which returns the value directly to the Switch Controller - i.e. instead of "vars.put()" use "return value". You could use BeansShell, Javascript or Jexl. > Regards, > Andrey > > > On Mon, Jul 7, 2008 at 4:35 PM, Ronan Klyne <[EMAIL PROTECTED]> wrote: > > Andrey Beznogov wrote: > >> > >> Hello. > >> > >> I was trying to prepare some tests using JMeter, and its seems that > >> existing logic controllers are just not enough. > >> > >> In my test plan, I wanted to have some branching - i.e. I wanted to > >> group together some test "branches" (Simple Controllers with some HTTP > >> Requests inside) under some ControllerX, so that for every iteration > >> only one of the branches will be ran with some set probability. So, > >> RandomController may be called a simpler version of such ControllerX - > >> since it also runs only one of its children, with equal probability > >> for all of them. > >> > >> What is the easiest way to implement such a controller in JMeter? As I > >> can see it now, it may be either done by e.g. using additional Java > >> code for Java Request Sampler (which will do the random choosing) plus > >> Switch Controller, or writing a custom Controller as a plugin (which > >> is most likely much harder). But who knows - maybe it was already done > >> before. What could you suggest? > >> > >> Regards, > >> Andrey > >> > > > > I did this with a bit of beanshell to do the weighted random selection and > > switch controller to do the actual switch. I'd paste the code in, but > > unfortunately I can't find it at present... > > > > # r > > > > -- > > Ronan Klyne > > Business Collaborator Developer > > Tel: +44 01189 028518 > > [EMAIL PROTECTED] > > www.groupbc.com > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > -- > diem perdidi > > > --------------------------------------------------------------------- > 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]