Package org.apache.hadoop.hbase.util
Class MovingAverage<T>
java.lang.Object
org.apache.hadoop.hbase.util.MovingAverage<T>
- Direct Known Subclasses:
SimpleMovingAverage
,WindowMovingAverage
The purpose of introduction of
In different situation, different
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. In different situation, different
MovingAverage
algorithm can be used based on needs.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract double
Get average execution time of the measured method.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.
-
Field Details
-
LOG
-
label
-
-
Constructor Details
-
MovingAverage
-
-
Method Details
-
start
Mark start time of an execution.- Returns:
- time in ns.
-
stop
Mark end time of an execution, and return its interval.- Parameters:
startTime
- start time of an execution- Returns:
- elapsed time
-
measure
Measure elapsed time of a measurable method.- Parameters:
measurable
- method implementsTimeMeasurable
- Returns:
- T it refers to the original return type of the measurable method
-
updateMostRecentTime
Update the most recent data.- Parameters:
elapsed
- elapsed time of the most recent measurement
-
getAverageTime
Get average execution time of the measured method.- Returns:
- average time in ns
-