diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/DebugTimer.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/DebugTimer.java index 241b88f64f..fa0a8bde8b 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/DebugTimer.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/DebugTimer.java @@ -6,6 +6,7 @@ class DebugTimer implements Timer { private final String tag; private long startTime; + private String sectionName; DebugTimer(String tag) { this.tag = tag; @@ -14,25 +15,27 @@ class DebugTimer implements Timer { private void reset() { startTime = -1; + sectionName = null; } @Override - public void start() { + public void start(String sectionName) { if (startTime != -1) { throw new IllegalStateException("Timer was already started"); } startTime = System.nanoTime(); + this.sectionName = sectionName; } @Override - public void stop(String message) { + public void stop() { if (startTime == -1) { throw new IllegalStateException("Timer was not started"); } float durationMs = (System.nanoTime() - startTime) / 1000000f; - Log.d(tag, String.format(message + ": %.3fms", durationMs)); + Log.d(tag, String.format(sectionName + ": %.3fms", durationMs)); reset(); } } diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyController.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyController.java index a7d2b06780..d5f2d541b7 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyController.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyController.java @@ -264,19 +264,19 @@ public void run() { modelsBeingBuilt = new ControllerModelList(getExpectedModelCount()); - timer.start(); + timer.start("Models built"); buildModels(); addCurrentlyStagedModelIfExists(); - timer.stop("Models built"); + timer.stop(); runInterceptors(); filterDuplicatesIfNeeded(modelsBeingBuilt); modelsBeingBuilt.freeze(); - timer.start(); + timer.start("Models diffed"); adapter.setModels(modelsBeingBuilt); // This timing is only right if diffing and model building are on the same thread - timer.stop("Models diffed"); + timer.stop(); modelsBeingBuilt = null; hasBuiltModelsEver = true; @@ -359,13 +359,13 @@ private void runInterceptors() { } } - timer.start(); + timer.start("Interceptors executed"); for (Interceptor interceptor : interceptors) { interceptor.intercept(modelsBeingBuilt); } - timer.stop("Interceptors executed"); + timer.stop(); if (modelInterceptorCallbacks != null) { for (ModelInterceptorCallback callback : modelInterceptorCallbacks) { @@ -537,7 +537,7 @@ private void filterDuplicatesIfNeeded(List> models) { return; } - timer.start(); + timer.start("Duplicates filtered"); Set modelIds = new HashSet<>(models.size()); ListIterator> modelIterator = models.listIterator(); @@ -562,7 +562,7 @@ private void filterDuplicatesIfNeeded(List> models) { } } - timer.stop("Duplicates filtered"); + timer.stop(); } private int findPositionOfDuplicate(List> models, EpoxyModel duplicateModel) { diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/NoOpTimer.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/NoOpTimer.java index 767745d666..1492b26b43 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/NoOpTimer.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/NoOpTimer.java @@ -2,12 +2,12 @@ class NoOpTimer implements Timer { @Override - public void start() { + public void start(String sectionName) { } @Override - public void stop(String message) { + public void stop() { } } diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/Timer.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/Timer.java index 2a0d799fd3..207ca47d7c 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/Timer.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/Timer.java @@ -1,6 +1,6 @@ package com.airbnb.epoxy; interface Timer { - void start(); - void stop(String message); + void start(String sectionName); + void stop(); }