summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2021-01-26 02:53:42 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-01-26 02:53:42 +0000
commitfbf6e5a11a46b4a29736e4c67418fe28b138e9fc (patch)
tree0d1a3c06565456510d4450d194c3fb37aceace2a
parent1d602a11165e94b9cb8bff510dce3916fd131b6b (diff)
parent75de8f22851090230dd6335a5cd50d71b0f0fec1 (diff)
Merge "Zero out newer metrics as first commit."
-rw-r--r--services/surfaceflinger/TimeStats/TimeStats.cpp46
-rw-r--r--services/surfaceflinger/tests/unittests/TimeStatsTest.cpp47
2 files changed, 93 insertions, 0 deletions
diff --git a/services/surfaceflinger/TimeStats/TimeStats.cpp b/services/surfaceflinger/TimeStats/TimeStats.cpp
index f4a0319e7c..5d387d68e8 100644
--- a/services/surfaceflinger/TimeStats/TimeStats.cpp
+++ b/services/surfaceflinger/TimeStats/TimeStats.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include <unordered_map>
#undef LOG_TAG
#define LOG_TAG "TimeStats"
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
@@ -87,6 +88,18 @@ std::string histogramToProtoByteString(const std::unordered_map<int32_t, int32_t
proto.serializeToString(&byteString);
return byteString;
}
+
+std::string frameRateVoteToProtoByteString(float refreshRate, int frameRateCompatibility,
+ int seamlessness) {
+ util::ProtoOutputStream proto;
+ proto.write(android::util::FIELD_TYPE_FLOAT | 1 /* field id */, refreshRate);
+ proto.write(android::util::FIELD_TYPE_ENUM | 2 /* field id */, frameRateCompatibility);
+ proto.write(android::util::FIELD_TYPE_ENUM | 3 /* field id */, seamlessness);
+
+ std::string byteString;
+ proto.serializeToString(&byteString);
+ return byteString;
+}
} // namespace
AStatsManager_PullAtomCallbackReturn TimeStats::populateGlobalAtom(AStatsEventList* data) {
@@ -121,6 +134,23 @@ AStatsManager_PullAtomCallbackReturn TimeStats::populateGlobalAtom(AStatsEventLi
mStatsDelegate->statsEventWriteInt32(event, mTimeStats.jankPayload.totalSFLongGpu);
mStatsDelegate->statsEventWriteInt32(event, mTimeStats.jankPayload.totalSFUnattributed);
mStatsDelegate->statsEventWriteInt32(event, mTimeStats.jankPayload.totalAppUnattributed);
+
+ // TODO: populate these with real values
+ mStatsDelegate->statsEventWriteInt32(event, 0); // total_janky_frames_sf_scheduling
+ mStatsDelegate->statsEventWriteInt32(event, 0); // total_jank_frames_sf_prediction_error
+ mStatsDelegate->statsEventWriteInt32(event, 0); // total_jank_frames_app_buffer_stuffing
+ mStatsDelegate->statsEventWriteInt32(event, 0); // display_refresh_rate_bucket
+ std::string sfDeadlineMissedBytes =
+ histogramToProtoByteString(std::unordered_map<int32_t, int32_t>(),
+ mMaxPulledHistogramBuckets);
+ mStatsDelegate->statsEventWriteByteArray(event, (const uint8_t*)sfDeadlineMissedBytes.c_str(),
+ sfDeadlineMissedBytes.size()); // sf_deadline_misses
+ std::string sfPredictionErrorBytes =
+ histogramToProtoByteString(std::unordered_map<int32_t, int32_t>(),
+ mMaxPulledHistogramBuckets);
+ mStatsDelegate->statsEventWriteByteArray(event, (const uint8_t*)sfPredictionErrorBytes.c_str(),
+ sfPredictionErrorBytes.size()); // sf_prediction_errors
+ mStatsDelegate->statsEventWriteInt32(event, 0); // render_rate_bucket
mStatsDelegate->statsEventBuild(event);
clearGlobalLocked();
@@ -174,6 +204,22 @@ AStatsManager_PullAtomCallbackReturn TimeStats::populateLayerAtom(AStatsEventLis
mStatsDelegate->statsEventWriteInt32(event, layer->jankPayload.totalSFUnattributed);
mStatsDelegate->statsEventWriteInt32(event, layer->jankPayload.totalAppUnattributed);
+ // TODO: populate these with real values
+ mStatsDelegate->statsEventWriteInt32(event, 0); // total_janky_frames_sf_scheduling
+ mStatsDelegate->statsEventWriteInt32(event, 0); // total_jank_frames_sf_prediction_error
+ mStatsDelegate->statsEventWriteInt32(event, 0); // total_jank_frames_app_buffer_stuffing
+ mStatsDelegate->statsEventWriteInt32(event, 0); // display_refresh_rate_bucket
+ mStatsDelegate->statsEventWriteInt32(event, 0); // render_rate_bucket
+ std::string frameRateVoteBytes = frameRateVoteToProtoByteString(0.0, 0, 0);
+ mStatsDelegate->statsEventWriteByteArray(event, (const uint8_t*)frameRateVoteBytes.c_str(),
+ frameRateVoteBytes.size()); // set_frame_rate_vote
+ std::string appDeadlineMissedBytes =
+ histogramToProtoByteString(std::unordered_map<int32_t, int32_t>(),
+ mMaxPulledHistogramBuckets);
+ mStatsDelegate
+ ->statsEventWriteByteArray(event, (const uint8_t*)appDeadlineMissedBytes.c_str(),
+ appDeadlineMissedBytes.size()); // app_deadline_misses
+
mStatsDelegate->statsEventBuild(event);
}
clearLayersLocked();
diff --git a/services/surfaceflinger/tests/unittests/TimeStatsTest.cpp b/services/surfaceflinger/tests/unittests/TimeStatsTest.cpp
index fb9afd4045..df4464ef52 100644
--- a/services/surfaceflinger/tests/unittests/TimeStatsTest.cpp
+++ b/services/surfaceflinger/tests/unittests/TimeStatsTest.cpp
@@ -932,6 +932,18 @@ std::string buildExpectedHistogramBytestring(const std::vector<int32_t>& times,
return byteString;
}
+std::string frameRateVoteToProtoByteString(float refreshRate, int frameRateCompatibility,
+ int seamlessness) {
+ util::ProtoOutputStream proto;
+ proto.write(android::util::FIELD_TYPE_FLOAT | 1 /* field id */, refreshRate);
+ proto.write(android::util::FIELD_TYPE_ENUM | 2 /* field id */, frameRateCompatibility);
+ proto.write(android::util::FIELD_TYPE_ENUM | 3 /* field id */, seamlessness);
+
+ std::string byteString;
+ proto.serializeToString(&byteString);
+ return byteString;
+}
+
std::string dumpByteStringHex(const std::string& str) {
std::stringstream ss;
ss << std::hex;
@@ -1002,6 +1014,7 @@ TEST_F(TimeStatsTest, globalStatsCallback) {
std::string expectedFrameDuration = buildExpectedHistogramBytestring({2}, {1});
std::string expectedRenderEngineTiming = buildExpectedHistogramBytestring({1, 2}, {1, 1});
+ std::string expectedEmptyHistogram = buildExpectedHistogramBytestring({}, {});
{
InSequence seq;
@@ -1031,6 +1044,22 @@ TEST_F(TimeStatsTest, globalStatsCallback) {
EXPECT_CALL(*mDelegate, statsEventWriteInt32(mDelegate->mEvent, 1));
EXPECT_CALL(*mDelegate, statsEventWriteInt32(mDelegate->mEvent, 1));
EXPECT_CALL(*mDelegate, statsEventWriteInt32(mDelegate->mEvent, 1));
+ EXPECT_CALL(*mDelegate, statsEventWriteInt32(mDelegate->mEvent, 0));
+ EXPECT_CALL(*mDelegate, statsEventWriteInt32(mDelegate->mEvent, 0));
+ EXPECT_CALL(*mDelegate, statsEventWriteInt32(mDelegate->mEvent, 0));
+ EXPECT_CALL(*mDelegate, statsEventWriteInt32(mDelegate->mEvent, 0));
+ EXPECT_CALL(*mDelegate,
+ statsEventWriteByteArray(mDelegate->mEvent,
+ BytesEq((const uint8_t*)expectedEmptyHistogram.c_str(),
+ expectedEmptyHistogram.size()),
+ expectedEmptyHistogram.size()));
+ EXPECT_CALL(*mDelegate,
+ statsEventWriteByteArray(mDelegate->mEvent,
+ BytesEq((const uint8_t*)expectedEmptyHistogram.c_str(),
+ expectedEmptyHistogram.size()),
+ expectedEmptyHistogram.size()));
+ EXPECT_CALL(*mDelegate, statsEventWriteInt32(mDelegate->mEvent, 0));
+
EXPECT_CALL(*mDelegate, statsEventBuild(mDelegate->mEvent));
}
EXPECT_EQ(AStatsManager_PULL_SUCCESS,
@@ -1083,6 +1112,8 @@ TEST_F(TimeStatsTest, layerStatsCallback_pullsAllAndClears) {
std::string expectedLatchToPresent = buildExpectedHistogramBytestring({2}, {1});
std::string expectedDesiredToPresent = buildExpectedHistogramBytestring({1}, {1});
std::string expectedPostToAcquire = buildExpectedHistogramBytestring({1}, {1});
+ std::string expectedFrameRateOverride = frameRateVoteToProtoByteString(0.0, 0, 0);
+ std::string expectedEmptyHistogram = buildExpectedHistogramBytestring({}, {});
{
InSequence seq;
EXPECT_CALL(*mDelegate,
@@ -1136,6 +1167,22 @@ TEST_F(TimeStatsTest, layerStatsCallback_pullsAllAndClears) {
EXPECT_CALL(*mDelegate, statsEventWriteInt32(mDelegate->mEvent, 1));
EXPECT_CALL(*mDelegate, statsEventWriteInt32(mDelegate->mEvent, 1));
EXPECT_CALL(*mDelegate, statsEventWriteInt32(mDelegate->mEvent, 1));
+ EXPECT_CALL(*mDelegate, statsEventWriteInt32(mDelegate->mEvent, 0));
+ EXPECT_CALL(*mDelegate, statsEventWriteInt32(mDelegate->mEvent, 0));
+ EXPECT_CALL(*mDelegate, statsEventWriteInt32(mDelegate->mEvent, 0));
+ EXPECT_CALL(*mDelegate, statsEventWriteInt32(mDelegate->mEvent, 0));
+ EXPECT_CALL(*mDelegate, statsEventWriteInt32(mDelegate->mEvent, 0));
+ EXPECT_CALL(*mDelegate,
+ statsEventWriteByteArray(mDelegate->mEvent,
+ BytesEq((const uint8_t*)
+ expectedFrameRateOverride.c_str(),
+ expectedFrameRateOverride.size()),
+ expectedFrameRateOverride.size()));
+ EXPECT_CALL(*mDelegate,
+ statsEventWriteByteArray(mDelegate->mEvent,
+ BytesEq((const uint8_t*)expectedEmptyHistogram.c_str(),
+ expectedEmptyHistogram.size()),
+ expectedEmptyHistogram.size()));
EXPECT_CALL(*mDelegate, statsEventBuild(mDelegate->mEvent));
}