Skip to content

Commit

Permalink
Map SystraceSection to Perfetto instrumentation if the latter is enabled
Browse files Browse the repository at this point in the history
Differential Revision: D67619443
  • Loading branch information
rshest authored and facebook-github-bot committed Dec 24, 2024
1 parent 974fdf9 commit 236e07c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/react-native/ReactCommon/cxxreact/SystraceSection.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
#include <fbsystrace.h>
#endif

#ifdef WITH_PERFETTO
#include <perfetto.h>
#include <reactperflogger/ReactPerfettoCategories.h>
#endif

#if defined(__APPLE__)
// This is required so that OS_LOG_TARGET_HAS_10_15_FEATURES will be set.
#include <os/trace_base.h>
Expand Down Expand Up @@ -44,6 +49,21 @@ namespace facebook::react {
* different values in different files, there is no inconsistency in the sizes
* of defined symbols.
*/
#elif defined(WITH_PERFETTO)
struct TraceSection {
public:
template <typename... ConvertsToStringPiece>
explicit TraceSection(
const __unused char* name,
__unused ConvertsToStringPiece&&... args) {
TRACE_EVENT_BEGIN("react-native", perfetto::DynamicString{name}, args...);
}

~TraceSection() {
TRACE_EVENT_END("react-native");
}
};
using SystraceSectionUnwrapped = TraceSection;
#elif defined(WITH_FBSYSTRACE)
struct ConcreteSystraceSection {
public:
Expand Down

0 comments on commit 236e07c

Please sign in to comment.