jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1380318 - /jmeter/trunk/src/components/org/apache/jmeter/assertions/CompareAssertion.java
Date Mon, 03 Sep 2012 19:39:42 GMT
Author: pmouawad
Date: Mon Sep  3 19:39:41 2012
New Revision: 1380318

URL: http://svn.apache.org/viewvc?rev=1380318&view=rev
Log:
Avoid StringBuilder creation in loops

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/assertions/CompareAssertion.java

Modified: jmeter/trunk/src/components/org/apache/jmeter/assertions/CompareAssertion.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/assertions/CompareAssertion.java?rev=1380318&r1=1380317&r2=1380318&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/assertions/CompareAssertion.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/assertions/CompareAssertion.java Mon Sep
 3 19:39:41 2012
@@ -68,6 +68,7 @@ public class CompareAssertion extends Ab
             long prevTime = -1;
             SampleResult prevResult = null;
             boolean success = true;
+            StringBuilder buf = new StringBuilder();
             for(SampleResult sResult : responses) {
                 long currentTime = sResult.getTime();
                 if (prevTime != -1) {
@@ -76,11 +77,11 @@ public class CompareAssertion extends Ab
                 }
                 if (!success) {
                     result.setFailure(true);
-                    StringBuilder buf = new StringBuilder();
+                    buf.setLength(0);
                     appendResultDetails(buf, prevResult);
                     buf.append(JMeterUtils.getResString("comparison_response_time")).append(prevTime);
                     result.addToBaseResult(buf.toString());
-                    buf = new StringBuilder();
+                    buf.setLength(0);
                     appendResultDetails(buf, sResult);
                     buf.append(JMeterUtils.getResString("comparison_response_time")).append(currentTime);
                     result.addToSecondaryResult(buf.toString());
@@ -101,6 +102,7 @@ public class CompareAssertion extends Ab
             String prevContent = null;
             SampleResult prevResult = null;
             boolean success = true;
+            StringBuilder buf = new StringBuilder();
             for (SampleResult sResult : responses) {
                 String currentContent = sResult.getResponseDataAsString();
                 currentContent = filterString(currentContent);
@@ -109,11 +111,11 @@ public class CompareAssertion extends Ab
                 }
                 if (!success) {
                     result.setFailure(true);
-                    StringBuilder buf = new StringBuilder();
+                    buf.setLength(0);
                     appendResultDetails(buf, prevResult);
                     buf.append(prevContent);
                     result.addToBaseResult(buf.toString());
-                    buf = new StringBuilder();
+                    buf.setLength(0);                    
                     appendResultDetails(buf, sResult);
                     buf.append(currentContent);
                     result.addToSecondaryResult(buf.toString());



Mime
View raw message