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

Commit cec2af51 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "SF TimeStats: add a debug function for global present to present time"

parents 5aedec95 91a8638b
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -13,8 +13,10 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include "timestatsproto/TimeStatsHelper.h"

#include <android-base/stringprintf.h>
#include <timestatsproto/TimeStatsHelper.h>
#include <inttypes.h>

#include <array>

@@ -46,6 +48,14 @@ void TimeStatsHelper::Histogram::insert(int32_t delta) {
    hist[*iter]++;
}

int64_t TimeStatsHelper::Histogram::totalTime() const {
    int64_t ret = 0;
    for (const auto& ele : hist) {
        ret += ele.first * ele.second;
    }
    return ret;
}

float TimeStatsHelper::Histogram::averageTime() const {
    int64_t ret = 0;
    int64_t count = 0;
@@ -87,12 +97,13 @@ std::string TimeStatsHelper::TimeStatsLayer::toString() const {

std::string TimeStatsHelper::TimeStatsGlobal::toString(std::optional<uint32_t> maxLayers) const {
    std::string result = "SurfaceFlinger TimeStats:\n";
    StringAppendF(&result, "statsStart = %lld\n", static_cast<long long int>(statsStart));
    StringAppendF(&result, "statsEnd = %lld\n", static_cast<long long int>(statsEnd));
    StringAppendF(&result, "statsStart = %" PRId64 "\n", statsStart);
    StringAppendF(&result, "statsEnd = %" PRId64 "\n", statsEnd);
    StringAppendF(&result, "totalFrames = %d\n", totalFrames);
    StringAppendF(&result, "missedFrames = %d\n", missedFrames);
    StringAppendF(&result, "clientCompositionFrames = %d\n", clientCompositionFrames);
    StringAppendF(&result, "displayOnTime = %lld ms\n", static_cast<long long int>(displayOnTime));
    StringAppendF(&result, "displayOnTime = %" PRId64 " ms\n", displayOnTime);
    StringAppendF(&result, "totalP2PTime = %" PRId64 " ms\n", presentToPresent.totalTime());
    StringAppendF(&result, "presentToPresent histogram is as below:\n");
    result.append(presentToPresent.toString());
    const auto dumpStats = generateDumpStats(maxLayers);
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ public:
        std::unordered_map<int32_t, int32_t> hist;

        void insert(int32_t delta);
        int64_t totalTime() const;
        float averageTime() const;
        std::string toString() const;
    };