diff --git a/packages/react-native/ReactCommon/react/nativemodule/webperformance/PerformanceEntryReporter.cpp b/packages/react-native/ReactCommon/react/nativemodule/webperformance/PerformanceEntryReporter.cpp index 1b1b376ebce..bd5447a3cc7 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/webperformance/PerformanceEntryReporter.cpp +++ b/packages/react-native/ReactCommon/react/nativemodule/webperformance/PerformanceEntryReporter.cpp @@ -155,13 +155,9 @@ void PerformanceEntryReporter::mark( const std::string& name, const std::optional& startTime) { logEntry(RawPerformanceEntry{ - name, - static_cast(PerformanceEntryType::MARK), - startTime ? *startTime : getCurrentTimeStamp(), - 0.0, - std::nullopt, - std::nullopt, - std::nullopt}); + .name = name, + .entryType = static_cast(PerformanceEntryType::MARK), + .startTime = startTime ? *startTime : getCurrentTimeStamp()}); } void PerformanceEntryReporter::clearEntries( @@ -257,25 +253,17 @@ void PerformanceEntryReporter::measure( double durationVal = duration ? *duration : endTimeVal - startTimeVal; logEntry( - {name, - static_cast(PerformanceEntryType::MEASURE), - startTimeVal, - durationVal, - std::nullopt, - std::nullopt, - std::nullopt}); + {.name = name, + .entryType = static_cast(PerformanceEntryType::MEASURE), + .startTime = startTimeVal, + .duration = durationVal}); } double PerformanceEntryReporter::getMarkTime( const std::string& markName) const { RawPerformanceEntry mark{ - markName, - static_cast(PerformanceEntryType::MARK), - 0.0, - 0.0, - std::nullopt, - std::nullopt, - std::nullopt}; + .name = markName, + .entryType = static_cast(PerformanceEntryType::MARK)}; std::lock_guard lock(nameLookupMutex_); const auto& marksBuffer = getBuffer(PerformanceEntryType::MARK); @@ -295,13 +283,13 @@ void PerformanceEntryReporter::logEventEntry( double processingEnd, uint32_t interactionId) { logEntry( - {std::move(name), - static_cast(PerformanceEntryType::EVENT), - startTime, - duration, - processingStart, - processingEnd, - interactionId}); + {.name = std::move(name), + .entryType = static_cast(PerformanceEntryType::EVENT), + .startTime = startTime, + .duration = duration, + .processingStart = processingStart, + .processingEnd = processingEnd, + .interactionId = interactionId}); } void PerformanceEntryReporter::scheduleFlushBuffer() { diff --git a/packages/react-native/ReactCommon/react/nativemodule/webperformance/tests/PerformanceEntryReporterTest.cpp b/packages/react-native/ReactCommon/react/nativemodule/webperformance/tests/PerformanceEntryReporterTest.cpp index 05ac75203d9..a2c495dd2f4 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/webperformance/tests/PerformanceEntryReporterTest.cpp +++ b/packages/react-native/ReactCommon/react/nativemodule/webperformance/tests/PerformanceEntryReporterTest.cpp @@ -104,34 +104,18 @@ TEST(PerformanceEntryReporter, PerformanceEntryReporterTestReportMarks) { ASSERT_EQ(4, entries.size()); const std::vector expected = { - {"mark0", - static_cast(PerformanceEntryType::MARK), - 0.0, - 0.0, - std::nullopt, - std::nullopt, - std::nullopt}, - {"mark1", - static_cast(PerformanceEntryType::MARK), - 1.0, - 0.0, - std::nullopt, - std::nullopt, - std::nullopt}, - {"mark2", - static_cast(PerformanceEntryType::MARK), - 2.0, - 0.0, - std::nullopt, - std::nullopt, - std::nullopt}, - {"mark0", - static_cast(PerformanceEntryType::MARK), - 3.0, - 0.0, - std::nullopt, - std::nullopt, - std::nullopt}, + {.name = "mark0", + .entryType = static_cast(PerformanceEntryType::MARK), + .startTime = 0.0}, + {.name = "mark1", + .entryType = static_cast(PerformanceEntryType::MARK), + .startTime = 1.0}, + {.name = "mark2", + .entryType = static_cast(PerformanceEntryType::MARK), + .startTime = 2.0}, + {.name = "mark0", + .entryType = static_cast(PerformanceEntryType::MARK), + .startTime = 3.0}, }; ASSERT_EQ(expected, entries); @@ -172,104 +156,56 @@ TEST(PerformanceEntryReporter, PerformanceEntryReporterTestReportMeasures) { ASSERT_EQ(0, res.droppedEntriesCount); const std::vector expected = { - {"mark0", - static_cast(PerformanceEntryType::MARK), - 0.0, - 0.0, - std::nullopt, - std::nullopt, - std::nullopt}, - {"measure0", - static_cast(PerformanceEntryType::MEASURE), - 0.0, - 2.0, - std::nullopt, - std::nullopt, - std::nullopt}, - {"measure1", - static_cast(PerformanceEntryType::MEASURE), - 0.0, - 4.0, - std::nullopt, - std::nullopt, - std::nullopt}, - {"mark1", - static_cast(PerformanceEntryType::MARK), - 1.0, - 0.0, - std::nullopt, - std::nullopt, - std::nullopt}, - {"measure2", - static_cast(PerformanceEntryType::MEASURE), - 1.0, - 1.0, - std::nullopt, - std::nullopt, - std::nullopt}, - {"measure7", - static_cast(PerformanceEntryType::MEASURE), - 1.0, - 2.0, - std::nullopt, - std::nullopt, - std::nullopt}, - {"measure3", - static_cast(PerformanceEntryType::MEASURE), - 1.0, - 5.0, - std::nullopt, - std::nullopt, - std::nullopt}, - {"measure4", - static_cast(PerformanceEntryType::MEASURE), - 1.5, - 0.5, - std::nullopt, - std::nullopt, - std::nullopt}, - {"mark2", - static_cast(PerformanceEntryType::MARK), - 2.0, - 0.0, - std::nullopt, - std::nullopt, - std::nullopt}, - {"mark3", - static_cast(PerformanceEntryType::MARK), - 2.0, - 0.0, - std::nullopt, - std::nullopt, - std::nullopt}, - {"mark4", - static_cast(PerformanceEntryType::MARK), - 2.0, - 0.0, - std::nullopt, - std::nullopt, - std::nullopt}, - {"measure6", - static_cast(PerformanceEntryType::MEASURE), - 2.0, - 0.0, - std::nullopt, - std::nullopt, - std::nullopt}, - {"measure5", - static_cast(PerformanceEntryType::MEASURE), - 2.0, - 1.5, - std::nullopt, - std::nullopt, - std::nullopt}, - {"mark4", - static_cast(PerformanceEntryType::MARK), - 3.0, - 0.0, - std::nullopt, - std::nullopt, - std::nullopt}}; + {.name = "mark0", + .entryType = static_cast(PerformanceEntryType::MARK), + .startTime = 0.0}, + {.name = "measure0", + .entryType = static_cast(PerformanceEntryType::MEASURE), + .startTime = 0.0, + .duration = 2.0}, + {.name = "measure1", + .entryType = static_cast(PerformanceEntryType::MEASURE), + .startTime = 0.0, + .duration = 4.0}, + {.name = "mark1", + .entryType = static_cast(PerformanceEntryType::MARK), + .startTime = 1.0}, + {.name = "measure2", + .entryType = static_cast(PerformanceEntryType::MEASURE), + .startTime = 1.0, + .duration = 1.0}, + {.name = "measure7", + .entryType = static_cast(PerformanceEntryType::MEASURE), + .startTime = 1.0, + .duration = 2.0}, + {.name = "measure3", + .entryType = static_cast(PerformanceEntryType::MEASURE), + .startTime = 1.0, + .duration = 5.0}, + {.name = "measure4", + .entryType = static_cast(PerformanceEntryType::MEASURE), + .startTime = 1.5, + .duration = 0.5}, + {.name = "mark2", + .entryType = static_cast(PerformanceEntryType::MARK), + .startTime = 2.0}, + {.name = "mark3", + .entryType = static_cast(PerformanceEntryType::MARK), + .startTime = 2.0}, + {.name = "mark4", + .entryType = static_cast(PerformanceEntryType::MARK), + .startTime = 2.0}, + {.name = "measure6", + .entryType = static_cast(PerformanceEntryType::MEASURE), + .startTime = 2.0, + .duration = 0.0}, + {.name = "measure5", + .entryType = static_cast(PerformanceEntryType::MEASURE), + .startTime = 2.0, + .duration = 1.5}, + {.name = "mark4", + .entryType = static_cast(PerformanceEntryType::MARK), + .startTime = 3.0}}; ASSERT_EQ(expected, entries); }