mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Expose API for registering processes and threads (#49083)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/49083 # Changelog: [Internal] > NOTE: Some CI jobs are expected to fail, because changes in Hermes D67353585 should be landed first, and then grafted to Static Hermes. Added 2 new public methods to `PerformanceTracer` instance for registering metadata Trace Events for processes and threads. Reviewed By: huntie Differential Revision: D68439733 fbshipit-source-id: dd9f0e72e2414b8c665c57a542cbbfe7df34a516
This commit is contained in:
committed by
Facebook GitHub Bot
parent
71f0b4d5a0
commit
acebebfd21
@@ -151,6 +151,40 @@ void PerformanceTracer::reportMeasure(
|
||||
});
|
||||
}
|
||||
|
||||
void PerformanceTracer::reportProcess(uint64_t id, const std::string& name) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (!tracing_) {
|
||||
return;
|
||||
}
|
||||
|
||||
buffer_.push_back(TraceEvent{
|
||||
.name = "process_name",
|
||||
.cat = "__metadata",
|
||||
.ph = 'M',
|
||||
.ts = 0,
|
||||
.pid = id,
|
||||
.tid = 0,
|
||||
.args = folly::dynamic::object("name", name),
|
||||
});
|
||||
}
|
||||
|
||||
void PerformanceTracer::reportThread(uint64_t id, const std::string& name) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (!tracing_) {
|
||||
return;
|
||||
}
|
||||
|
||||
buffer_.push_back(TraceEvent{
|
||||
.name = "thread_name",
|
||||
.cat = "__metadata",
|
||||
.ph = 'M',
|
||||
.ts = 0,
|
||||
.pid = processId_,
|
||||
.tid = id,
|
||||
.args = folly::dynamic::object("name", name),
|
||||
});
|
||||
}
|
||||
|
||||
folly::dynamic PerformanceTracer::serializeTraceEvent(TraceEvent event) const {
|
||||
folly::dynamic result = folly::dynamic::object;
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <folly/dynamic.h>
|
||||
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
@@ -66,6 +67,16 @@ class PerformanceTracer {
|
||||
uint64_t duration,
|
||||
const std::optional<DevToolsTrackEntryPayload>& trackMetadata);
|
||||
|
||||
/**
|
||||
* Record a corresponding Trace Event for OS-level process.
|
||||
*/
|
||||
void reportProcess(uint64_t id, const std::string& name);
|
||||
|
||||
/**
|
||||
* Record a corresponding Trace Event for OS-level thread.
|
||||
*/
|
||||
void reportThread(uint64_t id, const std::string& name);
|
||||
|
||||
private:
|
||||
PerformanceTracer();
|
||||
PerformanceTracer(const PerformanceTracer&) = delete;
|
||||
|
||||
Reference in New Issue
Block a user