Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c6f30115 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "TimeStats: avoid inf value in averageFPS" into rvc-dev am: dbc3025d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/11852484

Change-Id: Iadbdf653f861b741727f45f6f008368edf389577
parents 6376e1f6 dbc3025d
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -87,7 +87,9 @@ std::string TimeStatsHelper::TimeStatsLayer::toString() const {
    StringAppendF(&result, "badDesiredPresentFrames = %d\n", badDesiredPresentFrames);
    const auto iter = deltas.find("present2present");
    if (iter != deltas.end()) {
        StringAppendF(&result, "averageFPS = %.3f\n", 1000.0 / iter->second.averageTime());
        const float averageTime = iter->second.averageTime();
        const float averageFPS = averageTime < 1.0f ? 0.0f : 1000.0f / averageTime;
        StringAppendF(&result, "averageFPS = %.3f\n", averageFPS);
    }
    for (const auto& ele : deltas) {
        StringAppendF(&result, "%s histogram is as below:\n", ele.first.c_str());
+9 −0
Original line number Diff line number Diff line
@@ -833,6 +833,15 @@ TEST_F(TimeStatsTest, canDumpWithInvalidMaxLayers) {
    ASSERT_EQ(0, globalProto.stats_size());
}

TEST_F(TimeStatsTest, noInfInAverageFPS) {
    EXPECT_TRUE(inputCommand(InputCommand::ENABLE, FMT_STRING).empty());
    insertTimeRecord(NORMAL_SEQUENCE, LAYER_ID_0, 1, 1000000);
    insertTimeRecord(NORMAL_SEQUENCE, LAYER_ID_0, 2, 1000000);

    const std::string result(inputCommand(InputCommand::DUMP_ALL, FMT_STRING));
    EXPECT_THAT(result, HasSubstr("averageFPS = 0.000"));
}

namespace {
std::string buildExpectedHistogramBytestring(const std::vector<int32_t>& times,
                                             const std::vector<int32_t>& frameCounts) {