mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 12:45:37 +08:00
Add systrace support in Fabric C++
Summary: This diff adds systrace support in the C++ side of Fabric Reviewed By: ejanzer Differential Revision: D12861373 fbshipit-source-id: 0291f3e406f239bbef3686ac0bba6e9f1c7eac57
This commit is contained in:
committed by
Facebook Github Bot
parent
fe7eb61989
commit
7b04f6aeaa
49
ReactCommon/fabric/debug/SystraceSection.h
Normal file
49
ReactCommon/fabric/debug/SystraceSection.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
// Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
|
||||||
|
// This source code is licensed under the MIT license found in the
|
||||||
|
// LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef WITH_FBSYSTRACE
|
||||||
|
#include <fbsystrace.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace facebook {
|
||||||
|
namespace react {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a convenience class to avoid lots of verbose profiling
|
||||||
|
* #ifdefs. If WITH_FBSYSTRACE is not defined, the optimizer will
|
||||||
|
* remove this completely. If it is defined, it will behave as
|
||||||
|
* FbSystraceSection, with the right tag provided. Use two separate classes to
|
||||||
|
* to ensure that the ODR rule isn't violated, that is, if WITH_FBSYSTRACE has
|
||||||
|
* different values in different files, there is no inconsistency in the sizes
|
||||||
|
* of defined symbols.
|
||||||
|
*/
|
||||||
|
#ifdef WITH_FBSYSTRACE
|
||||||
|
struct ConcreteSystraceSection {
|
||||||
|
public:
|
||||||
|
template <typename... ConvertsToStringPiece>
|
||||||
|
explicit ConcreteSystraceSection(
|
||||||
|
const char *name,
|
||||||
|
ConvertsToStringPiece &&... args)
|
||||||
|
: m_section(TRACE_TAG_REACT_CXX_BRIDGE, name, args...) {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
fbsystrace::FbSystraceSection m_section;
|
||||||
|
};
|
||||||
|
using SystraceSection = ConcreteSystraceSection;
|
||||||
|
#else
|
||||||
|
struct DummySystraceSection {
|
||||||
|
public:
|
||||||
|
template <typename... ConvertsToStringPiece>
|
||||||
|
explicit DummySystraceSection(
|
||||||
|
const char *name,
|
||||||
|
ConvertsToStringPiece &&... args) {}
|
||||||
|
};
|
||||||
|
using SystraceSection = DummySystraceSection;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace react
|
||||||
|
} // namespace facebook
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "EventEmitter.h"
|
#include "EventEmitter.h"
|
||||||
|
|
||||||
|
#include <fabric/debug/SystraceSection.h>
|
||||||
#include <folly/dynamic.h>
|
#include <folly/dynamic.h>
|
||||||
|
|
||||||
#include "RawEvent.h"
|
#include "RawEvent.h"
|
||||||
@@ -46,6 +47,7 @@ void EventEmitter::dispatchEvent(
|
|||||||
const std::string &type,
|
const std::string &type,
|
||||||
const folly::dynamic &payload,
|
const folly::dynamic &payload,
|
||||||
const EventPriority &priority) const {
|
const EventPriority &priority) const {
|
||||||
|
SystraceSection s("EventEmitter::dispatchEvent");
|
||||||
auto eventDispatcher = eventDispatcher_.lock();
|
auto eventDispatcher = eventDispatcher_.lock();
|
||||||
if (!eventDispatcher) {
|
if (!eventDispatcher) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "UIManager.h"
|
#include "UIManager.h"
|
||||||
|
|
||||||
#include <fabric/core/ShadowNodeFragment.h>
|
#include <fabric/core/ShadowNodeFragment.h>
|
||||||
|
#include <fabric/debug/SystraceSection.h>
|
||||||
|
|
||||||
namespace facebook {
|
namespace facebook {
|
||||||
namespace react {
|
namespace react {
|
||||||
@@ -60,6 +61,7 @@ void UIManager::appendChild(
|
|||||||
void UIManager::completeSurface(
|
void UIManager::completeSurface(
|
||||||
SurfaceId surfaceId,
|
SurfaceId surfaceId,
|
||||||
const SharedShadowNodeUnsharedList &rootChildren) const {
|
const SharedShadowNodeUnsharedList &rootChildren) const {
|
||||||
|
SystraceSection s("FabricUIManager::completeSurface");
|
||||||
if (delegate_) {
|
if (delegate_) {
|
||||||
delegate_->uiManagerDidFinishTransaction(surfaceId, rootChildren);
|
delegate_->uiManagerDidFinishTransaction(surfaceId, rootChildren);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include "UIManagerBinding.h"
|
#include "UIManagerBinding.h"
|
||||||
|
|
||||||
|
#include <fabric/debug/SystraceSection.h>
|
||||||
|
|
||||||
#include <jsi/JSIDynamic.h>
|
#include <jsi/JSIDynamic.h>
|
||||||
|
|
||||||
namespace facebook {
|
namespace facebook {
|
||||||
@@ -69,6 +71,7 @@ void UIManagerBinding::dispatchEvent(
|
|||||||
auto eventTargetValue = jsi::Value::null();
|
auto eventTargetValue = jsi::Value::null();
|
||||||
|
|
||||||
if (eventTarget) {
|
if (eventTarget) {
|
||||||
|
SystraceSection s("UIManagerBinding::JSIDispatchFabricEventToTarget");
|
||||||
auto &eventTargetWrapper =
|
auto &eventTargetWrapper =
|
||||||
static_cast<const EventTargetWrapper &>(*eventTarget);
|
static_cast<const EventTargetWrapper &>(*eventTarget);
|
||||||
eventTargetValue = eventTargetWrapper.instanceHandle.lock(runtime);
|
eventTargetValue = eventTargetWrapper.instanceHandle.lock(runtime);
|
||||||
|
|||||||
Reference in New Issue
Block a user