*******************************************************************************/
package org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics;
+import org.eclipse.tracecompass.segmentstore.core.BasicSegment;
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;
}
/**
* @return minimum value
*/
public long getMin() {
- return fMin;
+ return fMin.getLength();
}
/**
* @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;
}
/*
* 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++;
/*
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;
}
}