analysis: Add totals to latency statistics view
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.timing.core / src / org / eclipse / tracecompass / analysis / timing / core / segmentstore / statistics / SegmentStoreStatistics.java
index d1f4a1dfbd36a0615239cde5036648c6acdc7b5f..f71c65198469148ac37c7d1ae8959b13362b6d9f 100644 (file)
@@ -11,6 +11,7 @@
  *******************************************************************************/
 package org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics;
 
+import org.eclipse.tracecompass.segmentstore.core.BasicSegment;
 import org.eclipse.tracecompass.segmentstore.core.ISegment;
 
 /**
@@ -19,21 +20,23 @@ import org.eclipse.tracecompass.segmentstore.core.ISegment;
  * @author Bernd Hufmann
  */
 public class SegmentStoreStatistics {
-    private long fMin;
-    private long fMax;
+    private ISegment fMin;
+    private ISegment fMax;
     private long fNbSegments;
     private double fAverage;
     private double fVariance;
+    private double fTotal;
 
     /**
      * Constructor
      */
     public SegmentStoreStatistics() {
-        fMin = Long.MAX_VALUE;
-        fMax = Long.MIN_VALUE;
+        fMin = new BasicSegment(0, Long.MAX_VALUE);
+        fMax = new BasicSegment(Long.MIN_VALUE, 0);
         fNbSegments = 0;
         fAverage = 0.0;
         fVariance = 0.0;
+        fTotal = 0.0;
     }
 
     /**
@@ -42,7 +45,7 @@ public class SegmentStoreStatistics {
      * @return minimum value
      */
     public long getMin() {
-        return fMin;
+        return fMin.getLength();
     }
 
     /**
@@ -51,6 +54,24 @@ public class SegmentStoreStatistics {
      * @return maximum value
      */
     public long getMax() {
+        return fMax.getLength();
+    }
+
+    /**
+     * Get segment with minimum length
+     *
+     * @return segment with minimum length
+     */
+    public ISegment getMinSegment() {
+        return fMin;
+    }
+
+    /**
+     * Get segment with maximum length
+     *
+     * @return segment with maximum length
+     */
+    public ISegment getMaxSegment() {
         return fMax;
     }
 
@@ -98,8 +119,10 @@ public class SegmentStoreStatistics {
         /*
          * Min and max are trivial, as well as number of segments
          */
-        fMin = Math.min(fMin, value);
-        fMax = Math.max(fMax, value);
+        long min = fMin.getLength();
+        long max = fMax.getLength();
+        fMin = min <= value ? fMin : segment;
+        fMax = max >= value ? fMax : segment;
 
         fNbSegments++;
         /*
@@ -108,5 +131,16 @@ public class SegmentStoreStatistics {
         double delta = value - fAverage;
         fAverage += delta / fNbSegments;
         fVariance += delta * (value - fAverage);
+        fTotal += value;
+    }
+
+    /**
+     * Get total value
+     *
+     * @return total value
+     * @since 1.1
+     */
+    public double getTotal() {
+        return fTotal;
     }
 }
This page took 0.026791 seconds and 5 git commands to generate.