jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1706620 - in /jmeter/trunk: src/components/org/apache/jmeter/control/RandomOrderController.java xdocs/changes.xml
Date Sat, 03 Oct 2015 20:10:26 GMT
Author: pmouawad
Date: Sat Oct  3 20:10:26 2015
New Revision: 1706620

URL: http://svn.apache.org/viewvc?rev=1706620&view=rev
Log:
Bug 58281 - RandomOrderController : Improve randomization algorithm performance 
Bugzilla Id: 58281

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/control/RandomOrderController.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/components/org/apache/jmeter/control/RandomOrderController.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/control/RandomOrderController.java?rev=1706620&r1=1706619&r2=1706620&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/control/RandomOrderController.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/control/RandomOrderController.java Sat Oct
 3 20:10:26 2015
@@ -17,11 +17,7 @@
 package org.apache.jmeter.control;
 
 import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.jmeter.testelement.TestElement;
+import java.util.Collections;
 
 /**
  * A controller that runs its children each at most once, but in a random order.
@@ -59,30 +55,6 @@ public class RandomOrderController exten
      * Replace the subControllersAndSamplers list with a reordered ArrayList.
      */
     private void reorder() {
-        int numElements = this.subControllersAndSamplers.size();
-
-        // Create a new list containing numElements null elements.
-        List<TestElement> reordered = new ArrayList<>(this.subControllersAndSamplers.size());
-        for (int i = 0; i < numElements; i++) {
-            reordered.add(null);
-        }
-
-        // Insert the subControllersAndSamplers into random list positions.
-        for (Iterator<TestElement> i = this.subControllersAndSamplers.iterator(); i.hasNext();)
{
-            int idx = (int) Math.floor(Math.random() * reordered.size());
-            while (true) {
-                if (idx == numElements) {
-                    idx = 0;
-                }
-                if (reordered.get(idx) == null) {
-                    reordered.set(idx, i.next());
-                    break;
-                }
-                idx++;
-            }
-        }
-
-        // Replace subControllersAndSamplers with reordered copy.
-        this.subControllersAndSamplers = reordered;
+        Collections.shuffle(subControllersAndSamplers);
     }
 }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1706620&r1=1706619&r2=1706620&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sat Oct  3 20:10:26 2015
@@ -96,6 +96,7 @@ Summary
 <h3>Controllers</h3>
 <ul>
     <li><bug>58406</bug>IfController : Use Nashorn Engine if available
for JavaScript evaluation</li>
+    <li><bug>58281</bug>RandomOrderController : Improve randomization algorithm
performance. Contributed by Graham Russell (jmeter at ham1.co.uk)</li> 
 </ul>
 
 <h3>Listeners</h3>



Mime
View raw message