@InterfaceAudience.Private public abstract class MovingAverage<T> extends Object
MovingAverage
mainly is to measure execution time of a
specific method, which can help us to know its performance fluctuation in response to different
machine states or situations, better case, then to act accordingly.
MovingAverage
algorithm can be used based on needs.Modifier and Type | Field and Description |
---|---|
protected String |
label |
private static org.slf4j.Logger |
LOG |
Modifier | Constructor and Description |
---|---|
protected |
MovingAverage(String label) |
Modifier and Type | Method and Description |
---|---|
abstract double |
getAverageTime()
Get average execution time of the measured method.
|
T |
measure(TimeMeasurable<T> measurable)
Measure elapsed time of a measurable method.
|
protected long |
start()
Mark start time of an execution.
|
protected long |
stop(long startTime)
Mark end time of an execution, and return its interval.
|
protected abstract void |
updateMostRecentTime(long elapsed)
Update the most recent data.
|
protected MovingAverage(String label)
protected long start()
protected long stop(long startTime)
startTime
- start time of an executionpublic T measure(TimeMeasurable<T> measurable)
measurable
- method implements TimeMeasurable
protected abstract void updateMostRecentTime(long elapsed)
elapsed
- elapsed time of the most recent measurementpublic abstract double getAverageTime()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.