Add more perf counters

Reviewed By: AaaChiuuu

Differential Revision: D5624307

fbshipit-source-id: a7fd744b7a1989f35efe99d7471337a411870934
This commit is contained in:
Alexey Lang
2017-08-17 07:54:18 -07:00
committed by Facebook Github Bot
parent 3c12faf01c
commit caaf7fd417
5 changed files with 149 additions and 64 deletions
@@ -8,6 +8,7 @@
*/
package com.facebook.react.uimanager;
import android.os.SystemClock;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.animation.Animation;
@@ -27,6 +28,7 @@ import com.facebook.systrace.SystraceMessage;
import com.facebook.yoga.YogaDirection;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
/**
@@ -43,8 +45,7 @@ public class UIImplementation {
private final ReactApplicationContext mReactContext;
protected final EventDispatcher mEventDispatcher;
private double mLayoutCount = 0.0;
private double mLayoutTimer = 0.0;
private long mLastCalculateLayoutTime = 0;
public UIImplementation(
ReactApplicationContext reactContext,
@@ -168,12 +169,12 @@ public class UIImplementation {
}
}
public double getLayoutCount() {
return mLayoutCount;
public void profileNextBatch() {
mOperationsQueue.profileNextBatch();
}
public double getLayoutTimer() {
return mLayoutTimer;
public Map<String, Long> getProfiledBatchPerfCounters() {
return mOperationsQueue.getProfiledBatchPerfCounters();
}
/**
@@ -555,10 +556,11 @@ public class UIImplementation {
"UIImplementation.dispatchViewUpdates")
.arg("batchId", batchId)
.flush();
final long commitStartTime = SystemClock.uptimeMillis();
try {
updateViewHierarchy();
mNativeViewHierarchyOptimizer.onBatchComplete();
mOperationsQueue.dispatchViewUpdates(batchId);
mOperationsQueue.dispatchViewUpdates(batchId, commitStartTime, mLastCalculateLayoutTime);
} finally {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
}
@@ -824,13 +826,12 @@ public class UIImplementation {
SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "cssRoot.calculateLayout")
.arg("rootTag", cssRoot.getReactTag())
.flush();
double startTime = (double) System.nanoTime();
long startTime = SystemClock.uptimeMillis();
try {
cssRoot.calculateLayout();
} finally {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
mLayoutTimer = mLayoutTimer + ((double)System.nanoTime() - startTime) / 1000000.0;
mLayoutCount = mLayoutCount + 1;
mLastCalculateLayoutTime = SystemClock.uptimeMillis() - startTime;
}
}