Package org.robolectric.util
Class PerfStatsCollector
- java.lang.Object
-
- org.robolectric.util.PerfStatsCollector
-
public class PerfStatsCollector extends Object
Collects performance statistics for later reporting viaPerfStatsReporter
.- Since:
- 3.6
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
PerfStatsCollector.Event
Event for perf stats collection.static interface
PerfStatsCollector.ThrowingRunnable<F extends Exception>
Runnable that throws an exception.static interface
PerfStatsCollector.ThrowingSupplier<T,F extends Exception>
Supplier that throws an exception.
-
Constructor Summary
Constructors Constructor Description PerfStatsCollector()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PerfStatsCollector
getInstance()
Metadata
getMetadata()
Collection<Metric>
getMetrics()
void
incrementCount(String eventName)
<E extends Exception>
voidmeasure(String eventName, PerfStatsCollector.ThrowingRunnable<E> runnable)
<T,E extends Exception>
Tmeasure(String eventName, PerfStatsCollector.ThrowingSupplier<T,E> supplier)
<T> void
putMetadata(Class<T> metadataClass, T metadata)
void
reset()
void
setEnabled(boolean isEnabled)
If not enabled, don't bother retaining perf stats, saving some memory and CPU cycles.PerfStatsCollector.Event
startEvent(String eventName)
-
-
-
Method Detail
-
getInstance
public static PerfStatsCollector getInstance()
-
setEnabled
public void setEnabled(boolean isEnabled)
If not enabled, don't bother retaining perf stats, saving some memory and CPU cycles.
-
startEvent
public PerfStatsCollector.Event startEvent(String eventName)
-
measure
public <T,E extends Exception> T measure(String eventName, PerfStatsCollector.ThrowingSupplier<T,E> supplier) throws E extends Exception
- Throws:
E extends Exception
-
incrementCount
public void incrementCount(String eventName)
-
measure
public <E extends Exception> void measure(String eventName, PerfStatsCollector.ThrowingRunnable<E> runnable) throws E extends Exception
- Throws:
E extends Exception
-
getMetrics
public Collection<Metric> getMetrics()
-
putMetadata
public <T> void putMetadata(Class<T> metadataClass, T metadata)
-
getMetadata
public Metadata getMetadata()
-
reset
public void reset()
-
-