SF Timestats: add new metrics
Add the new metrics below:
1) dropped buffers per layer
2) post to acquire histogram
Stop tracking the start and end time for each layer since that doesn't
give any meaningful information. The total/dropped frame per layer is
good enough for now.
Test: dumpsys SurfaceFlinger --timestats <see go/sf-timestats for args>
Bug: b/110954467
Change-Id: I1c8a3a6cc76b7ec4a2e9ab86d9237af95fe9d1e1
diff --git a/services/surfaceflinger/TimeStats/TimeStats.cpp b/services/surfaceflinger/TimeStats/TimeStats.cpp
index d7a2886..d77a324 100644
--- a/services/surfaceflinger/TimeStats/TimeStats.cpp
+++ b/services/surfaceflinger/TimeStats/TimeStats.cpp
@@ -178,10 +178,17 @@
if (!timeStats.stats.count(layerName)) {
timeStats.stats[layerName].layerName = layerName;
timeStats.stats[layerName].packageName = getPackageName(layerName);
- timeStats.stats[layerName].statsStart = static_cast<int64_t>(std::time(0));
}
TimeStatsHelper::TimeStatsLayer& timeStatsLayer = timeStats.stats[layerName];
timeStatsLayer.totalFrames++;
+ timeStatsLayer.droppedFrames += layerRecord.droppedFrames;
+ layerRecord.droppedFrames = 0;
+
+ const int32_t postToAcquireMs = msBetween(timeRecords[0].frameTime.postTime,
+ timeRecords[0].frameTime.acquireTime);
+ ALOGV("[%s]-[%" PRIu64 "]-post2acquire[%d]", layerName.c_str(),
+ timeRecords[0].frameTime.frameNumber, postToAcquireMs);
+ timeStatsLayer.deltas["post2acquire"].insert(postToAcquireMs);
const int32_t postToPresentMs = msBetween(timeRecords[0].frameTime.postTime,
timeRecords[0].frameTime.presentTime);
@@ -212,8 +219,6 @@
ALOGV("[%s]-[%" PRIu64 "]-present2present[%d]", layerName.c_str(),
timeRecords[0].frameTime.frameNumber, presentToPresentMs);
timeStatsLayer.deltas["present2present"].insert(presentToPresentMs);
-
- timeStats.stats[layerName].statsEnd = static_cast<int64_t>(std::time(0));
}
prevTimeRecord = timeRecords[0];
timeRecords.pop_front();
@@ -403,6 +408,7 @@
layerRecord.timeRecords.clear();
layerRecord.prevTimeRecord.ready = false;
layerRecord.waitData = -1;
+ layerRecord.droppedFrames = 0;
}
void TimeStats::removeTimeRecord(const std::string& layerName, uint64_t frameNumber) {
@@ -422,8 +428,9 @@
if (removeAt == layerRecord.timeRecords.size()) return;
layerRecord.timeRecords.erase(layerRecord.timeRecords.begin() + removeAt);
if (layerRecord.waitData > static_cast<int32_t>(removeAt)) {
- --layerRecord.waitData;
+ layerRecord.waitData--;
}
+ layerRecord.droppedFrames++;
}
void TimeStats::enable() {