SKETCH Add performance tracking for rendering

Differential Revision: D3709400

fbshipit-source-id: a006b60feb3fc5cb55cc2e6f08275fcc8de1d3e1
This commit is contained in:
Scott Buckfelder
2016-08-30 14:15:48 -07:00
committed by Facebook Github Bot 4
parent 5d32075363
commit 16f76d4407
4 changed files with 55 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ package com.facebook.react.uimanager;
import javax.annotation.Nullable;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import com.facebook.common.logging.FLog;
@@ -19,6 +20,7 @@ import com.facebook.react.animation.Animation;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.OnBatchCompleteListener;
import com.facebook.react.bridge.PerformanceCounter;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
@@ -60,7 +62,7 @@ import com.facebook.systrace.SystraceMessage;
* TODO(5483063): Don't dispatch the view hierarchy at the end of a batch if no UI changes occurred
*/
public class UIManagerModule extends ReactContextBaseJavaModule implements
OnBatchCompleteListener, LifecycleEventListener {
OnBatchCompleteListener, LifecycleEventListener, PerformanceCounter {
// Keep in sync with ReactIOSTagHandles JS module - see that file for an explanation on why the
// increment here is 10
@@ -135,6 +137,13 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
}
}
public Map<String,Double> getPerformanceCounters() {
Map<String,Double> perfMap = new HashMap<>();
perfMap.put("LayoutCount", mUIImplementation.getLayoutCount());
perfMap.put("LayoutTimer", mUIImplementation.getLayoutTimer());
return perfMap;
}
/**
* Registers a new root view. JS can use the returned tag with manageChildren to add/remove
* children to this view.