|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmessif.statistics.Statistics<StatisticSlidingAvgCounter>
messif.statistics.StatisticSlidingAvgCounter
public class StatisticSlidingAvgCounter
This is a statistic that counts aggregated functions (especially avg) from 1) last n values - if n+1 value is added, the first is removed and not considered any more or 2) values stored in the time-sliding window 3) combination of 1) and 2) Moreover, there is a possibility of linking each value (and time) with a "key" and then all values added to this counter are sumed up according to the key
Nested Class Summary | |
---|---|
protected static class |
StatisticSlidingAvgCounter.ValueTime
This simple class encapsulates the pair: double value + time when it was added |
Field Summary | |
---|---|
protected int |
count
|
protected long |
resetTime
Remember the time stamp of reseting (or creating) the statistics |
protected double |
sum
aggregated values |
Fields inherited from class messif.statistics.Statistics |
---|
replaceWith |
Constructor Summary | |
---|---|
protected |
StatisticSlidingAvgCounter(java.lang.String name)
Creates a new instance of StatisticSlidingAvgCounter |
Method Summary | |
---|---|
void |
addValue(double value)
add value and expect that it has been measured now - get current time |
void |
addValue(double value,
java.lang.Object obj)
add value and expect that it has been measured now - get current time. |
protected StatisticSlidingAvgCounter |
cast()
Returns this statistics as the type provided typed argument. |
double |
getAvg()
return average of the values in queue |
double |
getAvg(boolean consolidate)
return the average but do not consolidate the list of values if the parameter is false |
int |
getCnt()
return number of values in the queue |
double |
getMax()
return maximum value from the queue |
int |
getMaxNumberOfValues()
|
double |
getMin()
return minimum value from the queue |
static StatisticSlidingAvgCounter |
getStatistics(java.lang.String name)
Create new statistic counter with specified name or get the one already existing |
double |
getSum()
return the sum of queue values |
long |
getWindowSizeMilis()
|
boolean |
changedSinceCheckpoint()
Reports if value of min/max has been changed since the last setCheckpoint() call. |
boolean |
checkUsedTime()
Checks whether the sliding window was used for full time period |
void |
reset()
Reset the current statistic |
protected void |
setFrom(StatisticSlidingAvgCounter sourceStat)
Set this statistic to values from given statistic |
void |
setCheckpoint()
Sets checkpoint. |
void |
setMaxNumberOfValues(int maxNumberOfValues)
sets the size of window to consider |
void |
setWindowSizeMilis(long windowSizeMilis)
and sets the size of the time-sliding window in milis |
void |
shiftValuesByTime(long time)
add a given time difference to ALL values in the list |
java.lang.String |
toString()
Text representation of the SlidingWindow |
protected void |
updateFrom(StatisticSlidingAvgCounter sourceStat)
the final queue should be sorted according to time as required |
Methods inherited from class messif.statistics.Statistics |
---|
addBoundStat, bindTo, canPerformOperation, disableGlobally, enableGlobally, getAllStatistics, getAllStatistics, getBoundStats, getBoundTo, getName, getStatistics, isBound, isEnabledGlobally, isRegisteredGlobally, printStatistics, printStatistics, printStatistics, readResolve, removeBoundStat, removeStatistic, resetStatistics, resetStatistics, unbind |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected long resetTime
protected double sum
protected int count
Constructor Detail |
---|
protected StatisticSlidingAvgCounter(java.lang.String name)
Method Detail |
---|
public boolean checkUsedTime()
public int getMaxNumberOfValues()
public void setMaxNumberOfValues(int maxNumberOfValues)
maxNumberOfValues
- if < 0 then - use all valuespublic long getWindowSizeMilis()
public void setWindowSizeMilis(long windowSizeMilis)
windowSizeMilis
- if <= 0 - do not use the time windowpublic void shiftValuesByTime(long time)
public void addValue(double value)
public void addValue(double value, java.lang.Object obj)
public double getSum()
public int getCnt()
public double getAvg()
public double getAvg(boolean consolidate)
public double getMin()
public double getMax()
public static StatisticSlidingAvgCounter getStatistics(java.lang.String name) throws java.lang.ClassCastException
java.lang.ClassCastException
protected void updateFrom(StatisticSlidingAvgCounter sourceStat)
updateFrom
in class Statistics<StatisticSlidingAvgCounter>
sourceStat
- the statistic from which to update this statprotected void setFrom(StatisticSlidingAvgCounter sourceStat)
setFrom
in class Statistics<StatisticSlidingAvgCounter>
sourceStat
- the statistic from which to set this statpublic void reset()
reset
in class Statistics<StatisticSlidingAvgCounter>
public boolean changedSinceCheckpoint()
public void setCheckpoint()
public java.lang.String toString()
toString
in class java.lang.Object
protected StatisticSlidingAvgCounter cast()
Statistics
cast
in class Statistics<StatisticSlidingAvgCounter>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |