Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
c2ecb39e
Commit
c2ecb39e
authored
Feb 03, 2017
by
Björn Richerzhagen
Browse files
Capture the duration for a Descriptive Statistics measurement
parent
4dabbcdd
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/analyzer/metric/output/MetricOutputDAO.java
View file @
c2ecb39e
...
...
@@ -135,6 +135,8 @@ public class MetricOutputDAO extends AbstractOutput {
private
final
boolean
writeAggregates
;
private
final
Map
<
String
,
List
<
SimHost
>>
hostsByGroup
;
private
long
timestampLastEvent
=
-
1
;
public
MetricDaoAdapter
(
ActiveMetric
metric
)
{
this
.
metric
=
metric
;
...
...
@@ -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
());
...
...
src/de/tud/kom/p2psim/impl/util/db/dao/metric/MeasurementDAO.java
View file @
c2ecb39e
...
...
@@ -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
);
}
...
...
src/de/tud/kom/p2psim/impl/util/db/metric/MeasurementStatistic.java
View file @
c2ecb39e
...
...
@@ -58,19 +58,28 @@ 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
*/
@Column
(
nullable
=
true
,
name
=
"[values]"
)
private
Double
values
;
@Column
(
nullable
=
true
,
name
=
"[sum]"
)
private
Double
sum
;
@Column
(
nullable
=
true
,
name
=
"[sum2]"
)
private
Double
sum2
;
/**
* The minimum of all values for this measurement
*/
...
...
@@ -82,28 +91,34 @@ public class MeasurementStatistic implements GroupMetricBound {
*/
@Column
(
nullable
=
true
,
name
=
"[max]"
)
private
Double
max
;
@Column
(
nullable
=
true
,
name
=
"[mean]"
)
private
Double
mean
;
@Column
(
nullable
=
true
,
name
=
"[median]"
)
private
Double
median
;
@Column
(
nullable
=
true
,
name
=
"[perc25]"
)
private
Double
perc25
;
@Column
(
nullable
=
true
,
name
=
"[perc75]"
)
private
Double
perc75
;
@Column
(
nullable
=
true
,
name
=
"[perc97]"
)
private
Double
perc97
;
// 97,7
@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
;
@Column
(
nullable
=
true
,
name
=
"[kurtosis]"
)
private
Double
kurtosis
;
...
...
@@ -113,7 +128,7 @@ public class MeasurementStatistic implements GroupMetricBound {
@ManyToOne
(
cascade
=
CascadeType
.
ALL
)
@JoinColumn
(
name
=
"groupMetricId"
)
GroupMetric
groupMetric
;
/**
* Creates a {@link Measurement}-Object using the provided
* {@link DescriptiveStatistics} object.
...
...
@@ -125,26 +140,34 @@ 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
.
sum
=
checkForSpecialNumbers
(
stats
.
getSum
());
this
.
sum2
=
checkForSpecialNumbers
(
stats
.
getSumsq
());
this
.
min
=
checkForSpecialNumbers
(
stats
.
getMin
());
this
.
max
=
checkForSpecialNumbers
(
stats
.
getMax
());
...
...
@@ -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
());
}
...
...
@@ -178,12 +203,12 @@ public class MeasurementStatistic implements GroupMetricBound {
return
value
;
}
}
@Override
public
GroupMetric
getGroupMetric
()
{
return
groupMetric
;
}
@Override
public
void
setGroupMetric
(
GroupMetric
metric
)
{
this
.
groupMetric
=
metric
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment