Skip to content
Snippets Groups Projects
Commit 3f69df05 authored by Nils Christian Ehmke's avatar Nils Christian Ehmke
Browse files

Added naive implementation of the calculation for the average value

parent 500025a9
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,7 @@ public final class AggregatedExecutionEntry { ...@@ -28,6 +28,7 @@ public final class AggregatedExecutionEntry {
private final String operation; private final String operation;
private long minDuration; private long minDuration;
private long maxDuration; private long maxDuration;
private long avgDuration;
private int calls; private int calls;
public AggregatedExecutionEntry(final ExecutionEntry execEntry) { public AggregatedExecutionEntry(final ExecutionEntry execEntry) {
...@@ -75,6 +76,11 @@ public final class AggregatedExecutionEntry { ...@@ -75,6 +76,11 @@ public final class AggregatedExecutionEntry {
this.calls++; this.calls++;
this.minDuration = Math.min(this.minDuration, executionEntry.getDuration()); this.minDuration = Math.min(this.minDuration, executionEntry.getDuration());
this.maxDuration = Math.max(this.maxDuration, executionEntry.getDuration()); this.maxDuration = Math.max(this.maxDuration, executionEntry.getDuration());
this.avgDuration += executionEntry.getDuration();
}
public void recalculateValues() {
this.avgDuration /= this.calls;
} }
public long getMinDuration() { public long getMinDuration() {
...@@ -85,6 +91,10 @@ public final class AggregatedExecutionEntry { ...@@ -85,6 +91,10 @@ public final class AggregatedExecutionEntry {
return this.maxDuration; return this.maxDuration;
} }
public long getAvgDuration() {
return this.avgDuration;
}
public int getCalls() { public int getCalls() {
return this.calls; return this.calls;
} }
......
...@@ -46,6 +46,7 @@ public final class TraceAggregator extends AbstractConsumerStage<ExecutionEntry> ...@@ -46,6 +46,7 @@ public final class TraceAggregator extends AbstractConsumerStage<ExecutionEntry>
@Override @Override
public void onTerminating() throws Exception { public void onTerminating() throws Exception {
for (final AggregatedExecutionEntry aggregatedExecutionEntry : this.aggregationMap.values()) { for (final AggregatedExecutionEntry aggregatedExecutionEntry : this.aggregationMap.values()) {
aggregatedExecutionEntry.recalculateValues();
this.outputPort.send(aggregatedExecutionEntry); this.outputPort.send(aggregatedExecutionEntry);
} }
super.onTerminating(); super.onTerminating();
......
...@@ -21,6 +21,8 @@ public final class AggregatedTraceDetailComposite extends Composite { ...@@ -21,6 +21,8 @@ public final class AggregatedTraceDetailComposite extends Composite {
private final Label lblStackDepthDisplay; private final Label lblStackDepthDisplay;
private final Label lblMinimalDurationDisplay; private final Label lblMinimalDurationDisplay;
private final Label lblMaximalDurationDisplay; private final Label lblMaximalDurationDisplay;
private final Label lblAverageDuration;
private final Label lblAverageDurationDisplay;
public AggregatedTraceDetailComposite(final Composite parent, final int style) { public AggregatedTraceDetailComposite(final Composite parent, final int style) {
super(parent, style); super(parent, style);
...@@ -87,6 +89,14 @@ public final class AggregatedTraceDetailComposite extends Composite { ...@@ -87,6 +89,14 @@ public final class AggregatedTraceDetailComposite extends Composite {
this.lblMinimalDurationDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); this.lblMinimalDurationDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
this.lblMinimalDurationDisplay.setText("N/A"); this.lblMinimalDurationDisplay.setText("N/A");
this.lblAverageDuration = new Label(this, SWT.NONE);
this.lblAverageDuration.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
this.lblAverageDuration.setText("Average Duration:");
this.lblAverageDurationDisplay = new Label(this, SWT.NONE);
this.lblAverageDurationDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
this.lblAverageDurationDisplay.setText("N/A");
final Label lblMaximalDuration = new Label(this, SWT.NONE); final Label lblMaximalDuration = new Label(this, SWT.NONE);
lblMaximalDuration.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); lblMaximalDuration.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
lblMaximalDuration.setText("Maximal Duration:"); lblMaximalDuration.setText("Maximal Duration:");
...@@ -105,6 +115,7 @@ public final class AggregatedTraceDetailComposite extends Composite { ...@@ -105,6 +115,7 @@ public final class AggregatedTraceDetailComposite extends Composite {
this.lblMinimalDurationDisplay.setText(Long.toString(trace.getMinDuration())); this.lblMinimalDurationDisplay.setText(Long.toString(trace.getMinDuration()));
this.lblMaximalDurationDisplay.setText(Long.toString(trace.getMaxDuration())); this.lblMaximalDurationDisplay.setText(Long.toString(trace.getMaxDuration()));
this.lblAverageDurationDisplay.setText(Long.toString(trace.getAvgDuration()));
if (trace.isFailed()) { if (trace.isFailed()) {
this.lblFailedDisplay.setText("Yes (" + trace.getFailedCause() + ")"); this.lblFailedDisplay.setText("Yes (" + trace.getFailedCause() + ")");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment