Class PerfStatsCollector

java.lang.Object
org.robolectric.util.PerfStatsCollector

public class PerfStatsCollector extends Object
Collects performance statistics for later reporting via PerfStatsReporter.
Since:
3.6
  • Constructor Details

    • PerfStatsCollector

      public PerfStatsCollector()
  • Method Details

    • getInstance

      public static PerfStatsCollector 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

      public PerfStatsCollector.Event startEvent(String eventName)
    • measure

      public <T, E extends Exception> T measure(String eventName, PerfStatsCollector.ThrowingSupplier<T,E> supplier) throws E
      Throws:
      E
    • incrementCount

      public void incrementCount(String eventName)
    • recordCount

      public void recordCount(String eventName, int count)
      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

      public Collection<Metric> getMetrics()
    • putMetadata

      public void putMetadata(Metadata metadata)
    • getMetadata

      public Metadata getMetadata()
    • reset

      public void reset()