Commit c2ecb39e authored by Björn Richerzhagen's avatar Björn Richerzhagen
Browse files

Capture the duration for a Descriptive Statistics measurement

parent 4dabbcdd
......@@ -136,6 +136,8 @@ public class MetricOutputDAO extends AbstractOutput {
private final Map<String, List<SimHost>> hostsByGroup;
private long timestampLastEvent = -1;
public MetricDaoAdapter(ActiveMetric metric) {
this.metric = metric;
this.md = new MetricDescription(MetricOutputDAO.class.getName(),
......@@ -201,9 +203,14 @@ public class MetricOutputDAO extends AbstractOutput {
}
}
// Write Group stats
long observationDuration = Time.getCurrentTime() - timestampLastEvent;
if (timestampLastEvent == -1) {
observationDuration = Time.getCurrentTime() - timeEnableDao;
}
MeasurementDAO.storeGroupStatisticsMeasurement(md,
group, time, stats);
group, time, stats, observationDuration, false);
}
timestampLastEvent = Time.getCurrentTime();
} else {
for (SimHost host : hosts) {
MetricValue mv = metric.getPerHostMetric(host.getId());
......
......@@ -151,13 +151,21 @@ public class MeasurementDAO extends DAO {
* A time for the measurement in simulation time
* @param stats
* the {@link DescriptiveStatistics} object used as input
* @param observationDuration
* duration of this observation in simulation time
* @param describesWholeSimulation
* true, if this measurement is a description of the WHOLE
* simulation
*/
public static void storeGroupStatisticsMeasurement(
MetricDescription metricDesc, String groupName, long time,
DescriptiveStatistics stats) {
DescriptiveStatistics stats, long observationDuration,
boolean describesWholeSimulation) {
Metric metric = MetricDAO.lookupStatisticsMetric(metricDesc);
GroupMetric groupMetric = GroupMetricDAO.lookupGroupMetric(metric, groupName);
MeasurementStatistic measurement = new MeasurementStatistic(time, stats, groupMetric);
GroupMetric groupMetric = GroupMetricDAO.lookupGroupMetric(metric,
groupName);
MeasurementStatistic measurement = new MeasurementStatistic(time, stats,
groupMetric, observationDuration, describesWholeSimulation);
addToPersistQueue(measurement);
}
......
......@@ -58,6 +58,16 @@ public class MeasurementStatistic implements GroupMetricBound {
@Column(nullable = true, name = "[time]")
private long time;
@Column(nullable = false, name = "[describesWholeSimulation]")
private boolean describesWholeSimulation;
/**
* The simulation time for to this measurement in simulator time, that is,
* microseconds.
*/
@Column(nullable = true, name = "[observationDuration]")
private long observationDuration;
/**
* The number of values
*/
......@@ -70,7 +80,6 @@ public class MeasurementStatistic implements GroupMetricBound {
@Column(nullable = true, name = "[sum2]")
private Double sum2;
/**
* The minimum of all values for this measurement
*/
......@@ -101,6 +110,12 @@ public class MeasurementStatistic implements GroupMetricBound {
@Column(nullable = true, name = "[perc2]")
private Double perc2; // 2,3
@Column(nullable = true, name = "[perc95]")
private Double perc95; // 95
@Column(nullable = true, name = "[perc5]")
private Double perc5; // 5
@Column(nullable = true, name = "[skewness]")
private Double skewness;
......@@ -125,24 +140,32 @@ public class MeasurementStatistic implements GroupMetricBound {
* @param hostMetric
* The reference to the {@link HostMetric}-Object, which
* describes this metric. Is used for the mapping.
* @param observationDuration
* duration of the observation
* @param describesWholeSimulation
* true, if this measurement describes the whole simulation
*/
public MeasurementStatistic(long time, DescriptiveStatistics stats,
GroupMetric groupMetric) {
this(time, stats);
GroupMetric groupMetric, long observationDuration,
boolean describesWholeSimulation) {
this(time, stats, observationDuration, describesWholeSimulation);
this.groupMetric = groupMetric;
}
/**
* Internal - write statistics
*
* @param time
* @param stats
* @param observationDuration
* duration covered by this measurement in simulation units
*/
private MeasurementStatistic(long time, DescriptiveStatistics stats) {
private MeasurementStatistic(long time, DescriptiveStatistics stats,
long observationDuration, boolean describesWholeSimulation) {
super();
this.time = time;
/*
* TODO add stats
*/
this.observationDuration = observationDuration;
this.describesWholeSimulation = describesWholeSimulation;
this.values = checkForSpecialNumbers((double) stats.getN());
this.sum = checkForSpecialNumbers(stats.getSum());
this.sum2 = checkForSpecialNumbers(stats.getSumsq());
......@@ -154,6 +177,8 @@ public class MeasurementStatistic implements GroupMetricBound {
this.perc25 = checkForSpecialNumbers(stats.getPercentile(25));
this.perc75 = checkForSpecialNumbers(stats.getPercentile(75));
this.perc97 = checkForSpecialNumbers(stats.getPercentile(97.7));
this.perc5 = checkForSpecialNumbers(stats.getPercentile(5));
this.perc95 = checkForSpecialNumbers(stats.getPercentile(95));
this.skewness = checkForSpecialNumbers(stats.getSkewness());
this.kurtosis = checkForSpecialNumbers(stats.getKurtosis());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment