public class StatefulSystemMetricsCollector<R extends SystemMetrics<R>,S extends SystemMetricsCollector<R>>
extends java.lang.Object
Using this class makes it simple to share a single underlying collector instance, and manage state externally.
SystemMetricsCollector collector = ...; StatefulSystemMetricsCollector collector = new
StatefulSystemMetricsCollector(collector);
<p><p>// Every call gets the difference from the last call SystemMetrics metrics =
collector.getLatestDiffAndReset();
Note - creating a Stateful collector immediately takes an initial snapshot. - this class is _not_ thread safe.
Constructor and Description |
---|
StatefulSystemMetricsCollector(S collector)
Wrap the underlying collector to maintain external state: automatically takes a snapshot to
override the initial values.
|
StatefulSystemMetricsCollector(S collector,
R curr,
R prev,
R diff)
Wraps the underlying collector, but with custom metrics objects: useful for passing in custom
metrics objects, such as
WakeLockMetrics . |
Modifier and Type | Method and Description |
---|---|
S |
getCollector()
Access the underlying collector.
|
R |
getLatestDiff()
Get a diff form the previous baseline.
|
R |
getLatestDiffAndReset()
Get a diff from the previous baseline and update it.
|
public StatefulSystemMetricsCollector(S collector)
public StatefulSystemMetricsCollector(S collector, R curr, R prev, R diff)
WakeLockMetrics
.