Package org.apache.hadoop.util
Class CpuTimeTracker
java.lang.Object
org.apache.hadoop.util.CpuTimeTracker
Utility for sampling and computing CPU usage.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfloatReturn percentage of cpu time spent over the time since last update.longObtain the cumulative CPU time since the system is on.toString()voidupdateElapsedJiffies(BigInteger elapsedJiffies, long newTime) Apply delta to accumulators.
-
Field Details
-
UNAVAILABLE
public static final int UNAVAILABLE- See Also:
-
-
Constructor Details
-
CpuTimeTracker
public CpuTimeTracker(long jiffyLengthInMillis)
-
-
Method Details
-
getCpuTrackerUsagePercent
public float getCpuTrackerUsagePercent()Return percentage of cpu time spent over the time since last update. CPU time spent is based on elapsed jiffies multiplied by amount of time for 1 core. Thus, if you use 2 cores completely you would have spent twice the actual time between updates and this will return 200%.- Returns:
- Return percentage of cpu usage since last update,
UNAVAILABLEif there haven't been 2 updates more thanminimumTimeIntervalapart
-
getCumulativeCpuTime
public long getCumulativeCpuTime()Obtain the cumulative CPU time since the system is on.- Returns:
- cumulative CPU time in milliseconds
-
updateElapsedJiffies
Apply delta to accumulators.- Parameters:
elapsedJiffies- updated jiffiesnewTime- new sample time
-
toString
-