Package org.robolectric.util
Class PerfStatsCollector
java.lang.Object
org.robolectric.util.PerfStatsCollector
Collects performance statistics for later reporting via
PerfStatsReporter.- Since:
- 3.6
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassEvent for perf stats collection.static interfaceRunnable that throws an exception.static interfacePerfStatsCollector.ThrowingSupplier<T,F extends Exception> Supplier that throws an exception. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PerfStatsCollectorvoidincrementCount(String eventName) boolean<E extends Exception>
voidmeasure(String eventName, PerfStatsCollector.ThrowingRunnable<E> runnable) <T,E extends Exception>
Tmeasure(String eventName, PerfStatsCollector.ThrowingSupplier<T, E> supplier) voidputMetadata(Metadata metadata) voidrecordCount(String eventName, int count) Records a precise count for the given event.voidreset()voidsetEnabled(boolean isEnabled) Call to explicitly disable perf stats collection.startEvent(String eventName)
-
Constructor Details
-
PerfStatsCollector
public PerfStatsCollector()
-
-
Method Details
-
getInstance
-
setEnabled
public void setEnabled(boolean isEnabled) Call to explicitly disable perf stats collection.By default, the test runner will disable perf stats collection if there are no registered perf stats reporters.
Users can call this method to control perf stats collection regardless of the presence of perf stats reporters.
-
isEnabled
public boolean isEnabled() -
startEvent
-
measure
public <T,E extends Exception> T measure(String eventName, PerfStatsCollector.ThrowingSupplier<T, E> supplier) throws E- Throws:
E
-
incrementCount
-
recordCount
Records a precise count for the given event.Unlike
incrementCount(String), this method explicitly sets the count to the given value, overwriting any previous count. -
measure
public <E extends Exception> void measure(String eventName, PerfStatsCollector.ThrowingRunnable<E> runnable) throws E - Throws:
E
-
getMetrics
-
putMetadata
-
getMetadata
-
reset
public void reset()
-