@ThreadSafe public class StatMetric extends java.lang.Object implements java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
StatMetric.Metric |
Constructor and 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) |
Modifier and Type | Method and Description |
---|---|
double |
getAvg()
The average duration (in seconds) for this metric.
|
long |
getHits()
Deprecated.
|
double |
getLast()
The last duration in seconds.
|
long |
getLastUpdate()
The last timestamp that this statmetric was updated.
|
double |
getMax()
The maximum duration (in seconds) ever witnessed for this metric.
|
java.lang.Object |
getMetric(StatMetric.Metric metric) |
double |
getMin()
The minimum duration (in seconds) ever witnessed for this metric.
|
double |
getThroughput()
The current throughput for this metric (hits/second), or -1 if the metric is idle.
|
java.util.concurrent.TimeUnit |
getTimeUnit() |
long |
getTotal()
The total number of occurrences for this metric.
|
static void |
main(java.lang.String[] args) |
protected void |
onSetThroughput(double throughput)
Called when the throughput is updated.
|
void |
setTimeBetweenThroughputCalcs(int timeBetweenThroughputCalcs)
Set the amount of time that must pass between successive calculations of the throughput.
|
void |
setTimeUnit(java.util.concurrent.TimeUnit timeUnit) |
java.lang.String |
toString() |
void |
update(long startTime) |
void |
update(long startTime,
int count) |
public StatMetric()
public StatMetric(java.util.concurrent.TimeUnit timeUnit)
timeUnit
- TimeUnit to use. Only TimeUnit.MILLISECONDS or TimeUnit.SECONDS.public StatMetric(java.util.concurrent.TimeUnit timeUnit, int nRequiredForAverage)
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.public void setTimeBetweenThroughputCalcs(int timeBetweenThroughputCalcs)
public void update(long startTime)
public void update(long startTime, int count)
protected void onSetThroughput(double throughput)
public double getAvg()
@Deprecated public long getHits()
public long getTotal()
public double getMax()
public double getMin()
public double getLast()
public double getThroughput()
public long getLastUpdate()
public java.util.concurrent.TimeUnit getTimeUnit()
public void setTimeUnit(java.util.concurrent.TimeUnit timeUnit)
public java.lang.Object getMetric(StatMetric.Metric metric)
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)