Class StatMetric
- java.lang.Object
- 
- com.inductiveautomation.ignition.common.StatMetric
 
- 
- All Implemented Interfaces:
- java.io.Serializable
 
 @ThreadSafe public class StatMetric extends java.lang.Object implements java.io.Serializable A StatMetric keeps track of various statistics for one metric. For instance, the Metric might be "Requests". The statistics that can be kept are:- Total
- Average Duration
- Max Duration
- Min Duration
- Throughput
 - See Also:
- Serialized Form
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classStatMetric.Metric
 - 
Constructor SummaryConstructors Constructor Description StatMetric()Creates a StatMetric that tracks averages in TimeUnit.SECONDS.StatMetric(java.util.concurrent.TimeUnit timeUnit)StatMetric(java.util.concurrent.TimeUnit timeUnit, int nRequiredForAverage)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description doublegetAvg()The average duration (in seconds) for this metric.longgetHits()Deprecated.doublegetLast()The last duration in seconds.longgetLastUpdate()The last timestamp that this statmetric was updated.doublegetMax()The maximum duration (in seconds) ever witnessed for this metric.java.lang.ObjectgetMetric(StatMetric.Metric metric)doublegetMin()The minimum duration (in seconds) ever witnessed for this metric.doublegetThroughput()The current throughput for this metric (hits/second), or -1 if the metric is idle.java.util.concurrent.TimeUnitgetTimeUnit()longgetTotal()The total number of occurrences for this metric.static voidmain(java.lang.String[] args)protected voidonSetThroughput(double throughput)Called when the throughput is updated.voidsetTimeBetweenThroughputCalcs(int timeBetweenThroughputCalcs)Set the amount of time that must pass between successive calculations of the throughput.voidsetTimeUnit(java.util.concurrent.TimeUnit timeUnit)java.lang.StringtoString()voidupdate(long startTime)voidupdate(long startTime, int count)
 
- 
- 
- 
Constructor Detail- 
StatMetricpublic StatMetric() Creates a StatMetric that tracks averages in TimeUnit.SECONDS.
 - 
StatMetricpublic StatMetric(java.util.concurrent.TimeUnit timeUnit) - Parameters:
- timeUnit- TimeUnit to use. Only TimeUnit.MILLISECONDS or TimeUnit.SECONDS.
 
 - 
StatMetricpublic StatMetric(java.util.concurrent.TimeUnit timeUnit, int nRequiredForAverage)- Parameters:
- timeUnit- TimeUnit to use. Only TimeUnit.MILLISECONDS or TimeUnit.SECONDS.
- nRequiredForAverage- The number of calls to update() required to compute an average. Once reached, the average is computed using the last N values.
 
 
- 
 - 
Method Detail- 
setTimeBetweenThroughputCalcspublic void setTimeBetweenThroughputCalcs(int timeBetweenThroughputCalcs) Set the amount of time that must pass between successive calculations of the throughput.
 - 
updatepublic void update(long startTime) 
 - 
updatepublic void update(long startTime, int count)
 - 
onSetThroughputprotected void onSetThroughput(double throughput) Called when the throughput is updated. Override if desired.
 - 
getAvgpublic double getAvg() The average duration (in seconds) for this metric.
 - 
getHits@Deprecated public long getHits() Deprecated.
 - 
getTotalpublic long getTotal() The total number of occurrences for this metric.
 - 
getMaxpublic double getMax() The maximum duration (in seconds) ever witnessed for this metric.
 - 
getMinpublic double getMin() The minimum duration (in seconds) ever witnessed for this metric.
 - 
getLastpublic double getLast() The last duration in seconds.
 - 
getThroughputpublic double getThroughput() The current throughput for this metric (hits/second), or -1 if the metric is idle.
 - 
getLastUpdatepublic long getLastUpdate() The last timestamp that this statmetric was updated.- Returns:
- The last System.currentTimeMillis() that this StatMetric had update() called on it.
 
 - 
getTimeUnitpublic java.util.concurrent.TimeUnit getTimeUnit() 
 - 
setTimeUnitpublic void setTimeUnit(java.util.concurrent.TimeUnit timeUnit) 
 - 
getMetricpublic java.lang.Object getMetric(StatMetric.Metric metric) 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
mainpublic static void main(java.lang.String[] args) 
 
- 
 
-