[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jmeter-dev
Subject:    cvs commit: jakarta-jmeter/src/components/org/apache/jmeter/control ThroughputController.java
From:       jsalvata () apache ! org
Date:       2003-12-30 10:36:44
Message-ID: 20031230103644.29259.qmail () minotaur ! apache ! org
[Download RAW message or body]

jsalvata    2003/12/30 02:36:44

  Modified:    src/components/org/apache/jmeter/control
                        ThroughputController.java
  Log:
  Simplified.
  
  Fixed the two remaining test cases.
  
  PR: 23027
  
  Revision  Changes    Path
  1.14      +31 -55    jakarta-jmeter/src/components/org/apache/jmeter/control/ThroughputController.java
  
  Index: ThroughputController.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/control/ThroughputController.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ThroughputController.java	30 Dec 2003 01:19:52 -0000	1.13
  +++ ThroughputController.java	30 Dec 2003 10:36:44 -0000	1.14
  @@ -99,7 +99,7 @@
       private transient Object counterLock;
   
       /**
  -     * Number of completed executions.
  +     * Number of iterations on which we've chosen to deliver samplers.
        */
       private int numExecutions = 0;
       
  @@ -125,38 +125,6 @@
           runThisTime = false;
       }
   
  -    public void reInitialize()
  -    {
  -        runThisTime = false;
  -        super.reInitialize();
  -        
  -        int executions, iterations;
  -        boolean retval = false;
  -
  -        executions = getExecutions();
  -        iterations = getIteration();
  -        if (getStyle() == BYNUMBER)
  -        {
  -            if (executions < getMaxThroughputAsInt())
  -            {
  -                runThisTime = true;
  -            }
  -        }
  -        else
  -        {
  -            if (iterations == 0 && getPercentThroughputAsFloat() > 0)
  -            {
  -                runThisTime = true;
  -            }
  -            else if (
  -                ((float) executions / iterations) * 100
  -                    <= getPercentThroughputAsFloat())
  -            {
  -                runThisTime = true;
  -            }
  -        }
  -    }
  -
       public void setStyle(int style)
       {
           setProperty(new IntegerProperty(STYLE, style));
  @@ -306,9 +274,7 @@
        */
       public Sampler next()
       {
  -        if (runThisTime
  -            && getSubControllers().size() > 0
  -            && current < getSubControllers().size())
  +        if (runThisTime)
           {
               return super.next();
           }
  @@ -316,6 +282,26 @@
       }
   
       /**
  +     * Decide whether to return any samplers on this iteration.
  +     */
  +    private boolean decide()
  +    {
  +        int executions, iterations;
  +
  +        executions = getExecutions();
  +        iterations = getIteration();
  +        if (getStyle() == BYNUMBER)
  +        {
  +            return executions < getMaxThroughputAsInt();
  +        }
  +        else
  +        {
  +            return (100.0*executions+50.0) / (iterations+1)
  +                    < getPercentThroughputAsFloat();
  +        }
  +    }
  +
  +    /**
        * @see org.apache.jmeter.control.Controller#isDone()
        */
       public boolean isDone()
  @@ -326,7 +312,8 @@
           }
           else if (
               getStyle() == BYNUMBER
  -                && getExecutions() >= getMaxThroughputAsInt())
  +                && getExecutions() >= getMaxThroughputAsInt()
  +                && current >= getSubControllers().size())
           {
               return true;
           }
  @@ -365,26 +352,16 @@
               synchronized (counterLock)
               {
                   increaseIteration();
  -
  -                // Count the previous iteration as executed iif it was run:
  -                if (runThisTime)
  -                {
  -                    increaseExecutions();
  -                }
  +                runThisTime= decide();
  +                if (runThisTime) increaseExecutions();
               }
           }
           else
           {
               increaseIteration();
  -
  -            // Count the previous iteration as executed iif it was run:
  -            if (runThisTime)
  -            {
  -                increaseExecutions();
  -            }
  +            runThisTime= decide();
  +            if (runThisTime) increaseExecutions();
           }
  -        
  -        reInitialize();
       }
   
       /*
  @@ -581,7 +558,7 @@
               sub_1.addTestElement(new TestSampler("two"));
   
               LoopController controller = new LoopController();
  -            controller.setLoops(7);
  +            controller.setLoops(6);
               controller.addTestElement(new TestSampler("zero"));
               controller.addTestElement(sub_1);
               controller.addIterationListener(sub_1);
  @@ -606,8 +583,7 @@
                       "three",
                       "zero", // 2/6 vs. 3/6 -> 33.33 is closer to 33.33
                       "three",
  -                    "zero", // 2/7 vs. 3/7 --> 28.57 is closer to 33.33
  -                    "three",
  +                    // etc...
                   };
               int counter= 0;
               sub_1.testStarted();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic