diff --git a/packages/react-native/Libraries/WebPerformance/PerformanceEntryReporter.cpp b/packages/react-native/Libraries/WebPerformance/PerformanceEntryReporter.cpp index 8c82a5c2a9d..e223156ac94 100644 --- a/packages/react-native/Libraries/WebPerformance/PerformanceEntryReporter.cpp +++ b/packages/react-native/Libraries/WebPerformance/PerformanceEntryReporter.cpp @@ -72,7 +72,7 @@ GetPendingEntriesResult PerformanceEntryReporter::popPendingEntries() { } // Sort by starting time (or ending time, if starting times are equal) - std::sort( + std::stable_sort( res.entries.begin(), res.entries.end(), [](const RawPerformanceEntry &lhs, const RawPerformanceEntry &rhs) { diff --git a/packages/react-native/Libraries/WebPerformance/__tests__/PerformanceEntryReporterTest.cpp b/packages/react-native/Libraries/WebPerformance/__tests__/PerformanceEntryReporterTest.cpp index fb2dabc0d96..c5895021ee6 100644 --- a/packages/react-native/Libraries/WebPerformance/__tests__/PerformanceEntryReporterTest.cpp +++ b/packages/react-native/Libraries/WebPerformance/__tests__/PerformanceEntryReporterTest.cpp @@ -146,6 +146,10 @@ TEST(PerformanceEntryReporter, PerformanceEntryReporterTestReportMeasures) { reporter.measure("measure3", 0.0, 0.0, 5.0, "mark1"); reporter.measure("measure4", 1.5, 0.0, std::nullopt, std::nullopt, "mark2"); + reporter.mark("mark3", 2.0); + reporter.measure("measure5", 2.0, 2.0); + reporter.mark("mark4", 2.0); + auto res = reporter.popPendingEntries(); const auto &entries = res.entries; @@ -207,7 +211,29 @@ TEST(PerformanceEntryReporter, PerformanceEntryReporterTestReportMeasures) { 0.0, std::nullopt, 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}, + {"measure5", + static_cast(PerformanceEntryType::MEASURE), + 2.0, + 0.0, + std::nullopt, + std::nullopt, + std::nullopt}, + }; ASSERT_EQ(expected, entries); }