diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp b/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp index d6af5141346..3a75981d16e 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp @@ -34,6 +34,7 @@ bool PerformanceTracer::startTracing() { if (tracing_) { return false; } + tracing_ = true; return true; } @@ -43,6 +44,8 @@ bool PerformanceTracer::stopTracing() { if (!tracing_) { return false; } + + performanceMeasureCount_ = 0; tracing_ = false; return true; } @@ -158,14 +161,24 @@ void PerformanceTracer::reportMeasure( } } + ++performanceMeasureCount_; buffer_.push_back(TraceEvent{ + .id = performanceMeasureCount_, .name = std::string(name), .cat = "blink.user_timing", - .ph = 'X', + .ph = 'b', .ts = start, .pid = PID, // FIXME: This should be the real process ID. .tid = threadId, // FIXME: This should be the real thread ID. - .dur = duration, + }); + buffer_.push_back(TraceEvent{ + .id = performanceMeasureCount_, + .name = std::string(name), + .cat = "blink.user_timing", + .ph = 'e', + .ts = start + duration, + .pid = PID, // FIXME: This should be the real process ID. + .tid = threadId, // FIXME: This should be the real thread ID. }); } diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h b/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h index 19af05a16aa..25002c069a4 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h +++ b/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h @@ -76,6 +76,7 @@ class PerformanceTracer { folly::dynamic serializeTraceEvent(TraceEvent event) const; bool tracing_{false}; + uint32_t performanceMeasureCount_{0}; std::unordered_map customTrackIdMap_; std::vector buffer_; std::mutex mutex_;