public class CpuFrequencyMetricsCollector extends SystemMetricsCollector<CpuFrequencyMetrics>
Note that cpu frequencies are device wide and not specific to a process: this will be more accurate the more frequently it's sampled, but there are times when it will mis-attribute different frequencies while the instrumented app is inactive. The net cpu time of this app at those times should also be very low, so the net energy impact should not be too affected.
The available statistics are well documented on kernel.org at https://www.kernel.org/doc/Documentation/cpu-freq/cpufreq-stats.txt.
Constructor and Description |
---|
CpuFrequencyMetricsCollector() |
Modifier and Type | Method and Description |
---|---|
CpuFrequencyMetrics |
createMetrics()
Creates an empty instance of the corresponding system metrics.
|
protected java.lang.String |
getPath(int core) |
boolean |
getSnapshot(CpuFrequencyMetrics snapshot)
Note that access to snapshot instances is not synchronized and must be taken care of
by the caller requesting getSnapshot.
|
static int |
getTotalCores()
Returns total cores available on the system: note that this is different from
Runtime.availableProcessors() which will exclude currently offline processors. |
static void |
overrideCores()
Override cores: this only works /before/ the first call to getTotalCores.
|
public boolean getSnapshot(CpuFrequencyMetrics snapshot)
SystemMetricsCollector
getSnapshot
in class SystemMetricsCollector<CpuFrequencyMetrics>
snapshot
- snapshot on which the data will be writtenprotected java.lang.String getPath(int core)
public CpuFrequencyMetrics createMetrics()
SystemMetricsCollector
Explicitly having this function available reduces a significant amount of boilerplate
createMetrics
in class SystemMetricsCollector<CpuFrequencyMetrics>
public static int getTotalCores()
Runtime.availableProcessors()
which will exclude currently offline processors.public static void overrideCores()