jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1380583 - in /jmeter/trunk/src/functions/org/apache/jmeter/functions: IntSum.java LongSum.java
Date Tue, 04 Sep 2012 11:58:44 GMT
Author: pmouawad
Date: Tue Sep  4 11:58:43 2012
New Revision: 1380583

URL: http://svn.apache.org/viewvc?rev=1380583&view=rev
Log:
Use numeric test instead of relying on exception, should consume less CPU

Modified:
    jmeter/trunk/src/functions/org/apache/jmeter/functions/IntSum.java
    jmeter/trunk/src/functions/org/apache/jmeter/functions/LongSum.java

Modified: jmeter/trunk/src/functions/org/apache/jmeter/functions/IntSum.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/functions/org/apache/jmeter/functions/IntSum.java?rev=1380583&r1=1380582&r2=1380583&view=diff
==============================================================================
--- jmeter/trunk/src/functions/org/apache/jmeter/functions/IntSum.java (original)
+++ jmeter/trunk/src/functions/org/apache/jmeter/functions/IntSum.java Tue Sep  4 11:58:43
2012
@@ -22,6 +22,7 @@ import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.jmeter.engine.util.CompoundVariable;
 import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.samplers.Sampler;
@@ -68,10 +69,9 @@ public class IntSum extends AbstractFunc
             sum += Integer.parseInt(((CompoundVariable) values[i]).execute());
         }
 
-        try {
-            sum += Integer.parseInt(varName);
+        if(StringUtils.isNumeric(varName)) {
+            sum += Integer.parseInt(varName);        
             varName = null; // there is no variable name
-        } catch (NumberFormatException ignored) {
         }
 
         String totalString = Integer.toString(sum);

Modified: jmeter/trunk/src/functions/org/apache/jmeter/functions/LongSum.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/functions/org/apache/jmeter/functions/LongSum.java?rev=1380583&r1=1380582&r2=1380583&view=diff
==============================================================================
--- jmeter/trunk/src/functions/org/apache/jmeter/functions/LongSum.java (original)
+++ jmeter/trunk/src/functions/org/apache/jmeter/functions/LongSum.java Tue Sep  4 11:58:43
2012
@@ -22,6 +22,7 @@ import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.jmeter.engine.util.CompoundVariable;
 import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.samplers.Sampler;
@@ -67,10 +68,9 @@ public class LongSum extends AbstractFun
             sum += Long.parseLong(((CompoundVariable) values[i]).execute());
         }
 
-        try {
+        if(StringUtils.isNumeric(varName)) {
             sum += Long.parseLong(varName);
             varName = null; // there is no variable name
-        } catch (NumberFormatException ignored) {
         }
 
         String totalString = Long.toString(sum);



Mime
View raw message