jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1722395 - /jmeter/trunk/src/core/org/apache/jmeter/report/processor/ExternalSampleSorter.java
Date Wed, 30 Dec 2015 18:52:09 GMT
Author: fschumacher
Date: Wed Dec 30 18:52:09 2015
New Revision: 1722395

URL: http://svn.apache.org/viewvc?rev=1722395&view=rev
Log:
Extract a method for the complex decision logic, which sample should be written first in merge
mode.
Don't compare a boolean to true. Use it directly instead.

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/report/processor/ExternalSampleSorter.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/ExternalSampleSorter.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/ExternalSampleSorter.java?rev=1722395&r1=1722394&r2=1722395&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/processor/ExternalSampleSorter.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/ExternalSampleSorter.java Wed
Dec 30 18:52:09 2015
@@ -522,10 +522,7 @@ public class ExternalSampleSorter extend
                 if (l.hasNext() && r.hasNext()) {
                     Sample firstLeft = l.peek();
                     Sample firstRight = r.peek();
-                    if (!revertedSort
-                            && sampleComparator.compare(firstLeft, firstRight) <
0
-                            || revertedSort == true
-                            && sampleComparator.compare(firstLeft, firstRight) >=
0) {
+                    if (leftBeforeRight(firstLeft, firstRight)) {
                         csvWriter.write(firstLeft);
                         l.readSample();
                     } else {
@@ -549,10 +546,7 @@ public class ExternalSampleSorter extend
                 if (l.hasNext() && r.hasNext()) {
                     Sample firstLeft = l.peek();
                     Sample firstRight = r.peek();
-                    if (!revertedSort
-                            && sampleComparator.compare(firstLeft, firstRight) <
0
-                            || revertedSort == true
-                            && sampleComparator.compare(firstLeft, firstRight) >=
0) {
+                    if (leftBeforeRight(firstLeft, firstRight)) {
                         out.produce(firstLeft, 0);
                         l.readSample();
                     } else {
@@ -568,6 +562,24 @@ public class ExternalSampleSorter extend
         }
     }
 
+    /**
+     * Decides which sample should be written first given the configured
+     * {@link SampleComparator} and the sort order.
+     * 
+     * @param leftSample
+     *            the <em>left</em> sample
+     * @param rightSample
+     *            the <em>right</em> sample
+     * @return {@code true} when {@code leftSample} should be written first,
+     *         {@code false} otherwise
+     */
+    private boolean leftBeforeRight(Sample leftSample, Sample rightSample) {
+        return !revertedSort
+                && sampleComparator.compare(leftSample, rightSample) < 0
+                || revertedSort
+                && sampleComparator.compare(leftSample, rightSample) >= 0;
+    }
+
     private File getChunkFile() {
         DecimalFormat df = new DecimalFormat("00000");
         File out = new File(getWorkingDirectory(), "chunk-"



Mime
View raw message