mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 11:57:46 +08:00
SKETCH Add performance tracking for rendering
Differential Revision: D3709400 fbshipit-source-id: a006b60feb3fc5cb55cc2e6f08275fcc8de1d3e1
This commit is contained in:
committed by
Facebook Github Bot 4
parent
5d32075363
commit
16f76d4407
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
package com.facebook.react.bridge;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface PerformanceCounter {
|
||||
public Map<String,Double> getPerformanceCounters();
|
||||
}
|
||||
@@ -13,6 +13,8 @@ import javax.annotation.Nullable;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
@@ -143,6 +145,20 @@ public class ReactContext extends ContextWrapper {
|
||||
mLifecycleEventListeners.remove(listener);
|
||||
}
|
||||
|
||||
public Map<String, Map<String,Double>> getAllPerformanceCounters() {
|
||||
Map<String, Map<String,Double>> totalPerfMap =
|
||||
new HashMap<>();
|
||||
if (mCatalystInstance != null) {
|
||||
for (NativeModule nativeModule : mCatalystInstance.getNativeModules()) {
|
||||
if (nativeModule instanceof PerformanceCounter) {
|
||||
PerformanceCounter perfCounterModule = (PerformanceCounter) nativeModule;
|
||||
totalPerfMap.put(nativeModule.getName(), perfCounterModule.getPerformanceCounters());
|
||||
}
|
||||
}
|
||||
}
|
||||
return totalPerfMap;
|
||||
}
|
||||
|
||||
public void addActivityEventListener(ActivityEventListener listener) {
|
||||
mActivityEventListeners.add(listener);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user