You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2010/03/12 11:44:49 UTC
svn commit: r922204 - in /jakarta/jmeter/trunk: bin/jmeter.properties
src/core/org/apache/jmeter/samplers/StatisticalSampleResult.java
src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java
Author: sebb
Date: Fri Mar 12 10:44:48 2010
New Revision: 922204
URL: http://svn.apache.org/viewvc?rev=922204&view=rev
Log:
Revert to previous behaviour, i.e. key on thread Group, but allow this to be changed by defining key_on_threadname=true
Modified:
jakarta/jmeter/trunk/bin/jmeter.properties
jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleResult.java
jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java
Modified: jakarta/jmeter/trunk/bin/jmeter.properties
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/bin/jmeter.properties?rev=922204&r1=922203&r2=922204&view=diff
==============================================================================
--- jakarta/jmeter/trunk/bin/jmeter.properties (original)
+++ jakarta/jmeter/trunk/bin/jmeter.properties Fri Mar 12 10:44:48 2010
@@ -474,6 +474,8 @@ wmlParser.types=text/vnd.wap.wml
#mode=Batch
#mode=Hold
#mode=Statistical
+#Set to true to key statistical samples on threadName rather than threadGroup
+#key_on_threadname=false
#mode=Stripped
#mode=StrippedBatch
#mode=org.example.load.MySampleSender
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=922204&r1=922203&r2=922204&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 Fri Mar 12 10:44:48 2010
@@ -51,10 +51,19 @@ public class StatisticalSampleResult ext
super(stamp, elapsed);
}
- public StatisticalSampleResult(SampleResult res) {
+ /**
+ * Create a statistical sample result from an ordinary sample result.
+ *
+ * @param res the sample result
+ * @param keyOnThreadName true if key includes threadName, false if threadGroup
+ */
+ public StatisticalSampleResult(SampleResult res, boolean keyOnThreadName) {
// Copy data that is shared between samples (i.e. the key items):
setSampleLabel(res.getSampleLabel());
- setThreadName(res.getThreadName());
+
+ if (keyOnThreadName) {
+ setThreadName(res.getThreadName());
+ }
setSuccessful(true); // Assume result is OK
setSampleCount(0); // because we add the sample count in later
@@ -108,17 +117,22 @@ public class StatisticalSampleResult ext
/**
* Generates the key to be used for aggregating samples as follows:<br/>
- * <code>sampleLabel</code> "-" <code>threadName</code>
- *
+ * <code>sampleLabel</code> "-" <code>[threadName|threadGroup]</code>
+ * <p>
* N.B. the key should agree with the fixed items that are saved in the sample.
*
* @param event sample event whose key is to be calculated
+ * @param keyOnThreadName true if key should use thread name, otherwise use thread group
* @return the key to use for aggregating samples
*/
- public static String getKey(SampleEvent event) {
+ public static String getKey(SampleEvent event, boolean keyOnThreadName) {
StringBuilder sb = new StringBuilder(80);
sb.append(event.getResult().getSampleLabel());
- sb.append('-').append(event.getResult().getThreadName());
+ if (keyOnThreadName){
+ sb.append('-').append(event.getResult().getThreadName());
+ } else {
+ sb.append('-').append(event.getThreadGroup());
+ }
return sb.toString();
}
}
Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java?rev=922204&r1=922203&r2=922204&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java (original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java Fri Mar 12 10:44:48 2010
@@ -48,6 +48,9 @@ public class StatisticalSampleSender imp
private static final long TIME_THRESHOLD_MS = JMeterUtils.getPropDefault("time_threshold",
DEFAULT_TIME_THRESHOLD);
+ // should the samples be aggregated on thread name or thread group (default) ?
+ private static boolean KEY_ON_THREADNAME = JMeterUtils.getPropDefault("key_on_threadname", false);
+
private final RemoteSampleListener listener;
private final List<SampleEvent> sampleStore = new ArrayList<SampleEvent>();
@@ -75,8 +78,9 @@ public class StatisticalSampleSender imp
*/
StatisticalSampleSender(RemoteSampleListener listener) {
this.listener = listener;
- log.info("Using batching for this run." + " Thresholds: num="
- + NUM_SAMPLES_THRESHOLD + ", time=" + TIME_THRESHOLD_MS);
+ log.info("Using statistical sampling for this run." + " Thresholds: num="
+ + NUM_SAMPLES_THRESHOLD + ", time=" + TIME_THRESHOLD_MS
+ + ". Key uses ThreadName: " + KEY_ON_THREADNAME);
}
/**
@@ -123,10 +127,10 @@ public class StatisticalSampleSender imp
public void sampleOccurred(SampleEvent e) {
synchronized (sampleStore) {
// Locate the statistical sample colector
- String key = StatisticalSampleResult.getKey(e);
+ String key = StatisticalSampleResult.getKey(e, KEY_ON_THREADNAME);
StatisticalSampleResult statResult = sampleTable.get(key);
if (statResult == null) {
- statResult = new StatisticalSampleResult(e.getResult());
+ statResult = new StatisticalSampleResult(e.getResult(), KEY_ON_THREADNAME);
// store the new statistical result collector
sampleTable.put(key, statResult);
// add a new wrapper samplevent
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org