Java Code Examples for com.facebook.systrace.Systrace#beginAsyncSection()

The following examples show how to use com.facebook.systrace.Systrace#beginAsyncSection() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SystraceRequestListener.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
public void onProducerStart(String requestId, String producerName) {
  if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT_FRESCO)) {
    return;
  }

  StringBuilder entryName = new StringBuilder();
  entryName.append("FRESCO_PRODUCER_");
  entryName.append(producerName.replace(':', '_'));

  Pair<Integer,String> requestPair = Pair.create(mCurrentID, entryName.toString());
  Systrace.beginAsyncSection(
      Systrace.TRACE_TAG_REACT_FRESCO,
      requestPair.second,
      mCurrentID);
  mProducerID.put(requestId, requestPair);
  mCurrentID++;
}
 
Example 2
Source File: SystraceRequestListener.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
public void onRequestStart(
    ImageRequest request,
    Object callerContext,
    String requestId,
    boolean isPrefetch) {
  if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT_FRESCO)) {
    return;
  }

  StringBuilder entryName = new StringBuilder();
  entryName.append("FRESCO_REQUEST_");
  entryName.append(request.getSourceUri().toString().replace(':', '_'));

  Pair<Integer,String> requestPair = Pair.create(mCurrentID, entryName.toString());
  Systrace.beginAsyncSection(
      Systrace.TRACE_TAG_REACT_FRESCO,
      requestPair.second,
      mCurrentID);
  mRequestsID.put(requestId, requestPair);
  mCurrentID++;
}
 
Example 3
Source File: ReactInstanceManager.java    From react-native-GPay with MIT License 6 votes vote down vote up
private void attachRootViewToInstance(
    final ReactRootView rootView) {
  Log.d(ReactConstants.TAG, "ReactInstanceManager.attachRootViewToInstance()");
  Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "attachRootViewToInstance");
  UIManager uiManagerModule = UIManagerHelper.getUIManager(mCurrentReactContext, rootView.getUIManagerType());
  final int rootTag = uiManagerModule.addRootView(rootView);
  rootView.setRootViewTag(rootTag);
  rootView.runApplication();
  Systrace.beginAsyncSection(
    TRACE_TAG_REACT_JAVA_BRIDGE,
    "pre_rootView.onAttachedToReactInstance",
    rootTag);
  UiThreadUtil.runOnUiThread(new Runnable() {
    @Override
    public void run() {
      Systrace.endAsyncSection(
        TRACE_TAG_REACT_JAVA_BRIDGE,
        "pre_rootView.onAttachedToReactInstance",
        rootTag);
      rootView.onAttachedToReactInstance();
    }
  });
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}
 
Example 4
Source File: UIViewOperationQueue.java    From react-native-GPay with MIT License 5 votes vote down vote up
private void flushPendingBatches() {
  if (mIsInIllegalUIState) {
    FLog.w(
      ReactConstants.TAG,
      "Not flushing pending UI operations because of previously thrown Exception");
    return;
  }

  final ArrayList<Runnable> runnables;
  synchronized (mDispatchRunnablesLock) {
    if (!mDispatchUIRunnables.isEmpty()) {
      runnables = mDispatchUIRunnables;
      mDispatchUIRunnables = new ArrayList<>();
    } else {
      return;
    }
  }

  final long batchedExecutionStartTime = SystemClock.uptimeMillis();
  for (Runnable runnable : runnables) {
    runnable.run();
  }

  if (mIsProfilingNextBatch) {
    mProfiledBatchBatchedExecutionTime = SystemClock.uptimeMillis() - batchedExecutionStartTime;
    mProfiledBatchNonBatchedExecutionTime = mNonBatchedExecutionTotalTime;
    mIsProfilingNextBatch = false;

    Systrace.beginAsyncSection(
        Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
        "batchedExecutionTime",
        0,
        batchedExecutionStartTime * 1000000);
    Systrace.endAsyncSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "batchedExecutionTime", 0);
  }
  mNonBatchedExecutionTotalTime = 0;
}