Remove PerformanceEntryReporter::getCurrentTimeStamp (#53030)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53030

Changelog: [internal]

Removes `PerformanceEntryReporter::getCurrentTimeStamp` in favor of `HighResTimeStamp::now`, to make the source of truth more explicit.

Reviewed By: hoxyq

Differential Revision: D79560370

fbshipit-source-id: 0ccf2bf511781d3c47c6ddb4dd7f2061aab152b5
This commit is contained in:
Rubén Norte
2025-08-04 11:21:03 -07:00
committed by Facebook GitHub Bot
parent 7c1c833ee9
commit 21bccda26c
4 changed files with 9 additions and 16 deletions
@@ -79,7 +79,7 @@ void NetworkReporter::reportRequestStart(
int encodedDataLength,
const std::optional<ResponseInfo>& redirectResponse) {
if (ReactNativeFeatureFlags::enableResourceTimingAPI()) {
auto now = PerformanceEntryReporter::getInstance()->getCurrentTimeStamp();
auto now = HighResTimeStamp::now();
// All builds: Annotate PerformanceResourceTiming metadata
{
@@ -130,7 +130,7 @@ void NetworkReporter::reportConnectionTiming(
const std::string& requestId,
const std::optional<Headers>& headers) {
if (ReactNativeFeatureFlags::enableResourceTimingAPI()) {
auto now = PerformanceEntryReporter::getInstance()->getCurrentTimeStamp();
auto now = HighResTimeStamp::now();
// All builds: Annotate PerformanceResourceTiming metadata
{
@@ -164,7 +164,7 @@ void NetworkReporter::reportResponseStart(
const ResponseInfo& responseInfo,
int encodedDataLength) {
if (ReactNativeFeatureFlags::enableResourceTimingAPI()) {
auto now = PerformanceEntryReporter::getInstance()->getCurrentTimeStamp();
auto now = HighResTimeStamp::now();
// All builds: Annotate PerformanceResourceTiming metadata
{
@@ -229,7 +229,7 @@ void NetworkReporter::reportResponseEnd(
const std::string& requestId,
int encodedDataLength) {
if (ReactNativeFeatureFlags::enableResourceTimingAPI()) {
auto now = PerformanceEntryReporter::getInstance()->getCurrentTimeStamp();
auto now = HighResTimeStamp::now();
// All builds: Report PerformanceResourceTiming event
{
@@ -88,10 +88,6 @@ PerformanceEntryReporter::PerformanceEntryReporter()
#endif
}
HighResTimeStamp PerformanceEntryReporter::getCurrentTimeStamp() const {
return HighResTimeStamp::now();
}
void PerformanceEntryReporter::addEventTimingListener(
PerformanceEntryReporterEventTimingListener* listener) {
std::unique_lock lock(listenersMutex_);
@@ -68,8 +68,6 @@ class PerformanceEntryReporter {
PerformanceEntryType entryType,
const std::string& entryName);
HighResTimeStamp getCurrentTimeStamp() const;
void addEventTimingListener(
PerformanceEntryReporterEventTimingListener* listener);
void removeEventTimingListener(
@@ -123,9 +123,8 @@ EventTag EventPerformanceLogger::onEventStart(
// The event start timestamp may be provided by the caller in order to
// specify the platform specific event start time.
HighResTimeStamp timeStamp = eventStartTimeStamp
? *eventStartTimeStamp
: performanceEntryReporter->getCurrentTimeStamp();
HighResTimeStamp timeStamp =
eventStartTimeStamp ? *eventStartTimeStamp : HighResTimeStamp::now();
{
std::lock_guard lock(eventsInFlightMutex_);
eventsInFlight_.emplace(
@@ -140,7 +139,7 @@ void EventPerformanceLogger::onEventProcessingStart(EventTag tag) {
return;
}
auto timeStamp = performanceEntryReporter->getCurrentTimeStamp();
auto timeStamp = HighResTimeStamp::now();
{
std::lock_guard lock(eventsInFlightMutex_);
auto it = eventsInFlight_.find(tag);
@@ -156,7 +155,7 @@ void EventPerformanceLogger::onEventProcessingEnd(EventTag tag) {
return;
}
auto timeStamp = performanceEntryReporter->getCurrentTimeStamp();
auto timeStamp = HighResTimeStamp::now();
{
std::lock_guard lock(eventsInFlightMutex_);
auto it = eventsInFlight_.find(tag);
@@ -202,7 +201,7 @@ void EventPerformanceLogger::dispatchPendingEventTimingEntries(
performanceEntryReporter->reportEvent(
std::string(entry.name),
entry.startTime,
performanceEntryReporter->getCurrentTimeStamp() - entry.startTime,
HighResTimeStamp::now() - entry.startTime,
entry.processingStartTime.value(),
entry.processingEndTime.value(),
entry.interactionId);