org.apache.jmeter.reporters
public class: Summariser [javadoc |
source]
java.lang.Object
org.apache.jmeter.testelement.AbstractTestElement
org.apache.jmeter.reporters.Summariser
All Implemented Interfaces:
SampleListener, TestListener, Remoteable, NoThreadClone, Serializable, TestElement
Generate a summary of the test run so far to the log file and/or standard
output. Both running and differential totals are shown. Output is generated
every n seconds (default 3 minutes) on the appropriate time boundary, so that
multiple test runs on the same time will be synchronised.
This is mainly intended for batch (non-GUI) runs
Note that the RunningSample start and end times relate to the samples,
not the reporting interval.
Since the first sample in a delta is likely to have started in the previous reporting interval,
this means that the delta interval is likely to be longer than the reporting interval.
Also, the sum of the delta intervals will be larger than the overall elapsed time.
Data is accumulated according to the test element name.
Methods from org.apache.jmeter.testelement.AbstractTestElement: |
---|
addProperty, addTestElement, canRemove, clear, clearTemporary, clone, emptyTemporary, equals, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getThreadContext, getThreadName, isEnabled, isRunningVersion, isTemporary, logProperties, mergeIn, nextIsNull, propertyIterator, recoverRunningVersion, removeProperty, setName, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, threadFinished, threadStarted, traverse, traverseCollection, traverseMap, traverseProperty |
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from org.apache.jmeter.reporters.Summariser Detail: |
public void sampleOccurred(SampleEvent e) {
SampleResult s = e.getResult();
long now = System.currentTimeMillis() / 1000;// in seconds
RunningSample myDelta = null;
RunningSample myTotal = null;
boolean reportNow = false;
/*
* Have we reached the reporting boundary?
* Need to allow for a margin of error, otherwise can miss the slot.
* Also need to check we've not hit the window already
*/
synchronized (myTotals) {
if (s != null) {
myTotals.delta.addSample(s);
}
if ((now > myTotals.last + INTERVAL_WINDOW) && (now % INTERVAL < = INTERVAL_WINDOW)) {
reportNow = true;
// copy the data to minimise the synch time
myDelta = new RunningSample(myTotals.delta);
myTotals.moveDelta();
myTotal = new RunningSample(myTotals.total);
myTotals.last = now; // stop double-reporting
}
}
if (reportNow) {
String str;
str = format(myName, myDelta, "+");
if (TOLOG) {
log.info(str);
}
if (TOOUT) {
System.out.println(str);
}
// Only if we have updated them
if (myTotal != null && myDelta != null &&myTotal.getNumSamples() != myDelta.getNumSamples()) {
str = format(myName, myTotal, "=");
if (TOLOG) {
log.info(str);
}
if (TOOUT) {
System.out.println(str);
}
}
}
}
Accumulates the sample in two SampleResult objects - one for running
totals, and the other for deltas. |
public void sampleStarted(SampleEvent e) {
// not used
}
|
public void sampleStopped(SampleEvent e) {
// not used
}
|
public void testEnded() {
testEnded("local");
}
|
public void testEnded(String host) {
Object[] totals = null;
synchronized (accumulators) {
instanceCount--;
if (instanceCount < = 0){
totals = accumulators.entrySet().toArray();
}
}
if (totals == null) {// We're not done yet
return;
}
for (int i=0; i< totals.length; i++) {
Map.Entry me = (Map.Entry)totals[i];
String str;
String name = (String) me.getKey();
Totals total = (Totals) me.getValue();
// Only print final delta if there were some samples in the delta
// and there has been at least one sample reported previously
if (total.delta.getNumSamples() > 0 && total.total.getNumSamples() > 0) {
str = format(name, total.delta, "+");
if (TOLOG) {
log.info(str);
}
if (TOOUT) {
System.out.println(str);
}
}
total.moveDelta();
str = format(name, total.total, "=");
if (TOLOG) {
log.info(str);
}
if (TOOUT) {
System.out.println(str);
}
}
}
|
public void testIterationStart(LoopIterationEvent event) {
// not used
}
|
public void testStarted() {
testStarted("local");
}
|
public void testStarted(String host) {
synchronized (accumulators) {
myName = getName();
myTotals = (Totals) accumulators.get(myName);
if (myTotals == null){
myTotals = new Totals();
accumulators.put(myName, myTotals);
}
instanceCount++;
}
}
|