SF TimeStats: change the container of TimeRecord
The current container of TimeRecord is std::vector which behaves not
well when it tries to erase an element on the front. This change update
the container to std::deque instead.
Test: dumpsys SurfaceFlinger --timestats <see go/sf-timestats for args>
Bug: b/70388650
Change-Id: Ib3f695f46eb21dc27b0ed725b86764331f304be2
diff --git a/services/surfaceflinger/TimeStats/TimeStats.cpp b/services/surfaceflinger/TimeStats/TimeStats.cpp
index a6833a5..b207d99 100644
--- a/services/surfaceflinger/TimeStats/TimeStats.cpp
+++ b/services/surfaceflinger/TimeStats/TimeStats.cpp
@@ -152,7 +152,7 @@
LayerRecord& layerRecord = timeStatsTracker[layerName];
TimeRecord& prevTimeRecord = layerRecord.prevTimeRecord;
- std::vector<TimeRecord>& timeRecords = layerRecord.timeRecords;
+ std::deque<TimeRecord>& timeRecords = layerRecord.timeRecords;
while (!timeRecords.empty()) {
if (!recordReadyLocked(layerName, &timeRecords[0])) break;
ALOGV("[%s]-[%" PRIu64 "]-presentFenceTime[%" PRId64 "]", layerName.c_str(),
@@ -199,8 +199,7 @@
timeStats.stats[layerName].statsEnd = static_cast<int64_t>(std::time(0));
}
prevTimeRecord = timeRecords[0];
- // TODO(zzyiwei): change timeRecords to use std::deque
- timeRecords.erase(timeRecords.begin());
+ timeRecords.pop_front();
layerRecord.waitData--;
}
}