mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Use stable sort for performance entries (#36998)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/36998 For performance entries that have the same start/end time it makes more sense to report them back to `PerformanceObserver` in the same order they were logged. This kind of determinism is arguably better both in terms of API, and from the point of view of testing. Changelog: [Internal] Reviewed By: javache Differential Revision: D45142500 fbshipit-source-id: 77ff0093bead45dc2f15efc4b903dc181927565a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1250b8afb1
commit
8e046cbbd7
@@ -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) {
|
||||
|
||||
+27
-1
@@ -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<int>(PerformanceEntryType::MARK),
|
||||
2.0,
|
||||
0.0,
|
||||
std::nullopt,
|
||||
std::nullopt,
|
||||
std::nullopt},
|
||||
{"mark4",
|
||||
static_cast<int>(PerformanceEntryType::MARK),
|
||||
2.0,
|
||||
0.0,
|
||||
std::nullopt,
|
||||
std::nullopt,
|
||||
std::nullopt},
|
||||
{"measure5",
|
||||
static_cast<int>(PerformanceEntryType::MEASURE),
|
||||
2.0,
|
||||
0.0,
|
||||
std::nullopt,
|
||||
std::nullopt,
|
||||
std::nullopt},
|
||||
};
|
||||
|
||||
ASSERT_EQ(expected, entries);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user