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 {
...
@@ -135,6 +135,8 @@ public class MetricOutputDAO extends AbstractOutput {
private
final
boolean
writeAggregates
;
private
final
boolean
writeAggregates
;
private
final
Map
<
String
,
List
<
SimHost
>>
hostsByGroup
;
private
final
Map
<
String
,
List
<
SimHost
>>
hostsByGroup
;
private
long
timestampLastEvent
=
-
1
;
public
MetricDaoAdapter
(
ActiveMetric
metric
)
{
public
MetricDaoAdapter
(
ActiveMetric
metric
)
{
this
.
metric
=
metric
;
this
.
metric
=
metric
;
...
@@ -201,9 +203,14 @@ public class MetricOutputDAO extends AbstractOutput {
...
@@ -201,9 +203,14 @@ public class MetricOutputDAO extends AbstractOutput {
}
}
}
}
// Write Group stats
// Write Group stats
long
observationDuration
=
Time
.
getCurrentTime
()
-
timestampLastEvent
;
if
(
timestampLastEvent
==
-
1
)
{
observationDuration
=
Time
.
getCurrentTime
()
-
timeEnableDao
;
}
MeasurementDAO
.
storeGroupStatisticsMeasurement
(
md
,
MeasurementDAO
.
storeGroupStatisticsMeasurement
(
md
,
group
,
time
,
stats
);
group
,
time
,
stats
,
observationDuration
,
false
);
}
}
timestampLastEvent
=
Time
.
getCurrentTime
();
}
else
{
}
else
{
for
(
SimHost
host
:
hosts
)
{
for
(
SimHost
host
:
hosts
)
{
MetricValue
mv
=
metric
.
getPerHostMetric
(
host
.
getId
());
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 {
...
@@ -151,13 +151,21 @@ public class MeasurementDAO extends DAO {
* A time for the measurement in simulation time
* A time for the measurement in simulation time
* @param stats
* @param stats
* the {@link DescriptiveStatistics} object used as input
* 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
(
public
static
void
storeGroupStatisticsMeasurement
(
MetricDescription
metricDesc
,
String
groupName
,
long
time
,
MetricDescription
metricDesc
,
String
groupName
,
long
time
,
DescriptiveStatistics
stats
)
{
DescriptiveStatistics
stats
,
long
observationDuration
,
boolean
describesWholeSimulation
)
{
Metric
metric
=
MetricDAO
.
lookupStatisticsMetric
(
metricDesc
);
Metric
metric
=
MetricDAO
.
lookupStatisticsMetric
(
metricDesc
);
GroupMetric
groupMetric
=
GroupMetricDAO
.
lookupGroupMetric
(
metric
,
groupName
);
GroupMetric
groupMetric
=
GroupMetricDAO
.
lookupGroupMetric
(
metric
,
MeasurementStatistic
measurement
=
new
MeasurementStatistic
(
time
,
stats
,
groupMetric
);
groupName
);
MeasurementStatistic
measurement
=
new
MeasurementStatistic
(
time
,
stats
,
groupMetric
,
observationDuration
,
describesWholeSimulation
);
addToPersistQueue
(
measurement
);
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 {
...
@@ -58,19 +58,28 @@ public class MeasurementStatistic implements GroupMetricBound {
@Column
(
nullable
=
true
,
name
=
"[time]"
)
@Column
(
nullable
=
true
,
name
=
"[time]"
)
private
long
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
* The number of values
*/
*/
@Column
(
nullable
=
true
,
name
=
"[values]"
)
@Column
(
nullable
=
true
,
name
=
"[values]"
)
private
Double
values
;
private
Double
values
;
@Column
(
nullable
=
true
,
name
=
"[sum]"
)
@Column
(
nullable
=
true
,
name
=
"[sum]"
)
private
Double
sum
;
private
Double
sum
;
@Column
(
nullable
=
true
,
name
=
"[sum2]"
)
@Column
(
nullable
=
true
,
name
=
"[sum2]"
)
private
Double
sum2
;
private
Double
sum2
;
/**
/**
* The minimum of all values for this measurement
* The minimum of all values for this measurement
*/
*/
...
@@ -82,28 +91,34 @@ public class MeasurementStatistic implements GroupMetricBound {
...
@@ -82,28 +91,34 @@ public class MeasurementStatistic implements GroupMetricBound {
*/
*/
@Column
(
nullable
=
true
,
name
=
"[max]"
)
@Column
(
nullable
=
true
,
name
=
"[max]"
)
private
Double
max
;
private
Double
max
;
@Column
(
nullable
=
true
,
name
=
"[mean]"
)
@Column
(
nullable
=
true
,
name
=
"[mean]"
)
private
Double
mean
;
private
Double
mean
;
@Column
(
nullable
=
true
,
name
=
"[median]"
)
@Column
(
nullable
=
true
,
name
=
"[median]"
)
private
Double
median
;
private
Double
median
;
@Column
(
nullable
=
true
,
name
=
"[perc25]"
)
@Column
(
nullable
=
true
,
name
=
"[perc25]"
)
private
Double
perc25
;
private
Double
perc25
;
@Column
(
nullable
=
true
,
name
=
"[perc75]"
)
@Column
(
nullable
=
true
,
name
=
"[perc75]"
)
private
Double
perc75
;
private
Double
perc75
;
@Column
(
nullable
=
true
,
name
=
"[perc97]"
)
@Column
(
nullable
=
true
,
name
=
"[perc97]"
)
private
Double
perc97
;
// 97,7
private
Double
perc97
;
// 97,7
@Column
(
nullable
=
true
,
name
=
"[perc2]"
)
@Column
(
nullable
=
true
,
name
=
"[perc2]"
)
private
Double
perc2
;
// 2,3
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]"
)
@Column
(
nullable
=
true
,
name
=
"[skewness]"
)
private
Double
skewness
;
private
Double
skewness
;
@Column
(
nullable
=
true
,
name
=
"[kurtosis]"
)
@Column
(
nullable
=
true
,
name
=
"[kurtosis]"
)
private
Double
kurtosis
;
private
Double
kurtosis
;
...
@@ -113,7 +128,7 @@ public class MeasurementStatistic implements GroupMetricBound {
...
@@ -113,7 +128,7 @@ public class MeasurementStatistic implements GroupMetricBound {
@ManyToOne
(
cascade
=
CascadeType
.
ALL
)
@ManyToOne
(
cascade
=
CascadeType
.
ALL
)
@JoinColumn
(
name
=
"groupMetricId"
)
@JoinColumn
(
name
=
"groupMetricId"
)
GroupMetric
groupMetric
;
GroupMetric
groupMetric
;
/**
/**
* Creates a {@link Measurement}-Object using the provided
* Creates a {@link Measurement}-Object using the provided
* {@link DescriptiveStatistics} object.
* {@link DescriptiveStatistics} object.
...
@@ -125,26 +140,34 @@ public class MeasurementStatistic implements GroupMetricBound {
...
@@ -125,26 +140,34 @@ public class MeasurementStatistic implements GroupMetricBound {
* @param hostMetric
* @param hostMetric
* The reference to the {@link HostMetric}-Object, which
* The reference to the {@link HostMetric}-Object, which
* describes this metric. Is used for the mapping.
* 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
,
public
MeasurementStatistic
(
long
time
,
DescriptiveStatistics
stats
,
GroupMetric
groupMetric
)
{
GroupMetric
groupMetric
,
long
observationDuration
,
this
(
time
,
stats
);
boolean
describesWholeSimulation
)
{
this
(
time
,
stats
,
observationDuration
,
describesWholeSimulation
);
this
.
groupMetric
=
groupMetric
;
this
.
groupMetric
=
groupMetric
;
}
}
/**
/**
* Internal - write statistics
* Internal - write statistics
*
* @param time
* @param time
* @param stats
* @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
();
super
();
this
.
time
=
time
;
this
.
time
=
time
;
/*
this
.
observationDuration
=
observationDuration
;
* TODO add stats
this
.
describesWholeSimulation
=
describesWholeSimulation
;
*/
this
.
values
=
checkForSpecialNumbers
((
double
)
stats
.
getN
());
this
.
values
=
checkForSpecialNumbers
((
double
)
stats
.
getN
());
this
.
sum
=
checkForSpecialNumbers
(
stats
.
getSum
());
this
.
sum
=
checkForSpecialNumbers
(
stats
.
getSum
());
this
.
sum2
=
checkForSpecialNumbers
(
stats
.
getSumsq
());
this
.
sum2
=
checkForSpecialNumbers
(
stats
.
getSumsq
());
this
.
min
=
checkForSpecialNumbers
(
stats
.
getMin
());
this
.
min
=
checkForSpecialNumbers
(
stats
.
getMin
());
this
.
max
=
checkForSpecialNumbers
(
stats
.
getMax
());
this
.
max
=
checkForSpecialNumbers
(
stats
.
getMax
());
...
@@ -154,6 +177,8 @@ public class MeasurementStatistic implements GroupMetricBound {
...
@@ -154,6 +177,8 @@ public class MeasurementStatistic implements GroupMetricBound {
this
.
perc25
=
checkForSpecialNumbers
(
stats
.
getPercentile
(
25
));
this
.
perc25
=
checkForSpecialNumbers
(
stats
.
getPercentile
(
25
));
this
.
perc75
=
checkForSpecialNumbers
(
stats
.
getPercentile
(
75
));
this
.
perc75
=
checkForSpecialNumbers
(
stats
.
getPercentile
(
75
));
this
.
perc97
=
checkForSpecialNumbers
(
stats
.
getPercentile
(
97.7
));
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
.
skewness
=
checkForSpecialNumbers
(
stats
.
getSkewness
());
this
.
kurtosis
=
checkForSpecialNumbers
(
stats
.
getKurtosis
());
this
.
kurtosis
=
checkForSpecialNumbers
(
stats
.
getKurtosis
());
}
}
...
@@ -178,12 +203,12 @@ public class MeasurementStatistic implements GroupMetricBound {
...
@@ -178,12 +203,12 @@ public class MeasurementStatistic implements GroupMetricBound {
return
value
;
return
value
;
}
}
}
}
@Override
@Override
public
GroupMetric
getGroupMetric
()
{
public
GroupMetric
getGroupMetric
()
{
return
groupMetric
;
return
groupMetric
;
}
}
@Override
@Override
public
void
setGroupMetric
(
GroupMetric
metric
)
{
public
void
setGroupMetric
(
GroupMetric
metric
)
{
this
.
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