Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ReactCommon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ endif(WIN32)

if(ANDROID)
set(SOURCES ${SOURCES}
cxxreact/fbsystrace.cpp
cxxreact/JSBigString.cpp
)
endif(ANDROID)
Expand Down
1 change: 0 additions & 1 deletion ReactCommon/cxxreact/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ LOCAL_MODULE := reactnative

LOCAL_SRC_FILES := \
CxxNativeModule.cpp \
fbsystrace.cpp \
Instance.cpp \
JSBigString.cpp \
JSBundleType.cpp \
Expand Down
69 changes: 19 additions & 50 deletions ReactCommon/cxxreact/SystraceSection.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,71 +9,40 @@
#include <fbsystrace.h>
#endif

#include <string>
#include <chrono>

namespace facebook {
namespace react {

void SystraceBeginSection(const char* name, const char* args) noexcept;
void SystraceEndSection(const char* name, const char* args, std::chrono::nanoseconds duration) noexcept;

/**
* 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.
* 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.
*/
struct SystraceSection {
public:
template<typename... ConvertsToStringPiece>
explicit SystraceSection(const char* name, ConvertsToStringPiece&&... args)
#ifdef WITH_FBSYSTRACE
: m_section(TRACE_TAG_REACT_CXX_BRIDGE, name, std::forward<ConvertsToStringPiece>(args)...)
#elif defined(WITH_OFFICE_TRACING)
: m_start(std::chrono::steady_clock::now())
, m_name{name}
, m_args{concatArgs(std::forward<ConvertsToStringPiece>(args)...)}
{
SystraceBeginSection(m_name.c_str(), m_args.c_str());
}

~SystraceSection()
{
SystraceEndSection(m_name.c_str(), m_args.c_str(), std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::steady_clock::now()-m_start));
}

private:
std::string concatArgs() noexcept
{
return "";
}

struct ConcreteSystraceSection {
public:
template<typename... ConvertsToStringPiece>
std::string concatArgs(const char* name, const std::string& value, ConvertsToStringPiece&&... rest) noexcept
{
return std::string(name) + "=" + value + "|" + concatArgs(std::forward<ConvertsToStringPiece>(rest)...);
}
#else
explicit
ConcreteSystraceSection(__unused const char* name, __unused ConvertsToStringPiece&&... args)
: m_section(TRACE_TAG_REACT_CXX_BRIDGE, name, args...)
{}
#endif

#ifdef WITH_FBSYSTRACE
private:
fbsystrace::FbSystraceSection m_section;
#elif defined(WITH_OFFICE_TRACING)
std::string m_name;
std::string m_args;
std::chrono::time_point<std::chrono::steady_clock> m_start;
#endif
};

// Some placeholder definitions to satisfy linker.. as we are enabling some unintented code paths when enabling these macros.
#if defined(WITH_OFFICE_TRACING)
#define TRACE_TAG_REACT_CXX_BRIDGE 0
struct FbSystraceAsyncFlow{
static void begin(uint64_t /*tag*/, const char* /*name*/, int /*cookie*/) {}
static void end(uint64_t /*tag*/, const char* /*name*/, int /*cookie*/) {}
using SystraceSection = ConcreteSystraceSection;
#else
struct DummySystraceSection {
public:
template<typename... ConvertsToStringPiece>
explicit
DummySystraceSection(__unused const char* name, __unused ConvertsToStringPiece&&... args)
{}
};
using SystraceSection = DummySystraceSection;
#endif

}}
67 changes: 0 additions & 67 deletions ReactCommon/cxxreact/fbsystrace.cpp

This file was deleted.

70 changes: 0 additions & 70 deletions ReactCommon/cxxreact/fbsystrace.h

This file was deleted.