Author: sebb Date: Thu Mar 11 23:33:24 2010 New Revision: 922069 URL: http://svn.apache.org/viewvc?rev=922069&view=rev Log: Bug 48889 - Wrong response time with mode=Statistical and num_sample_threshold > 1 Maintain elapsed time locally; change to threadName key to allow its use in aggregate sample
Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleResult.java Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleResult.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleResult.java?rev=922069&r1=922068&r2=922069&view=diff ============================================================================== --- jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleResult.java (original) +++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleResult.java Thu Mar 11 23:33:24 2010 @@ -28,10 +28,13 @@ import java.io.Serializable; public class StatisticalSampleResult extends SampleResult implements Serializable { - private static final long serialVersionUID = 24L; + private static final long serialVersionUID = 240L; private int errorCount; + // Need to maintain our own elapsed timer to ensure more accurate aggregation + private long elapsed; + public StatisticalSampleResult(){// May be called by XStream } @@ -51,10 +54,11 @@ public class StatisticalSampleResult ext public StatisticalSampleResult(SampleResult res) { // Copy data that is shared between samples (i.e. the key items): setSampleLabel(res.getSampleLabel()); - // Nothing else can be saved, as the samples may come from any thread + setThreadName(res.getThreadName()); setSuccessful(true); // Assume result is OK setSampleCount(0); // because we add the sample count in later + elapsed = 0; } public void add(SampleResult res) { @@ -79,11 +83,12 @@ public class StatisticalSampleResult ext setLatency(getLatency()+ res.getLatency()); + elapsed += res.getTime(); } @Override public long getTime() { - return getEndTime() - getStartTime() - this.getIdleTime(); + return elapsed; } @Override @@ -103,7 +108,7 @@ public class StatisticalSampleResult ext /** * Generates the key to be used for aggregating samples as follows:<br/> - * <code>sampleLabel</code> "-" <code>threadGroup</code> + * <code>sampleLabel</code> "-" <code>threadName</code> * * N.B. the key should agree with the fixed items that are saved in the sample. * @@ -112,7 +117,8 @@ public class StatisticalSampleResult ext */ public static String getKey(SampleEvent event) { StringBuilder sb = new StringBuilder(80); - sb.append(event.getResult().getSampleLabel()).append("-").append(event.getThreadGroup()); + sb.append(event.getResult().getSampleLabel()); + sb.append('-').append(event.getResult().getThreadName()); return sb.toString(); } } --------------------------------------------------------------------- To unsubscribe, e-mail: jmeter-dev-unsubscr...@jakarta.apache.org For additional commands, e-mail: jmeter-dev-h...@jakarta.apache.org