blob: c793941d4905f809e13d2e1e41a04a36ad4afbff [file] [log] [blame]
Yiwei Zhang0102ad22018-05-02 17:37:17 -07001/*
2 * Copyright 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -080016
17// TODO(b/129481165): remove the #pragma below and fix conversion issues
18#pragma clang diagnostic push
19#pragma clang diagnostic ignored "-Wconversion"
Yiwei Zhang0102ad22018-05-02 17:37:17 -070020#undef LOG_TAG
21#define LOG_TAG "TimeStats"
22#define ATRACE_TAG ATRACE_TAG_GRAPHICS
23
24#include "TimeStats.h"
25
26#include <android-base/stringprintf.h>
Yiwei Zhang0102ad22018-05-02 17:37:17 -070027#include <log/log.h>
Yiwei Zhang0102ad22018-05-02 17:37:17 -070028#include <utils/String8.h>
Yiwei Zhang3a226d22018-10-16 09:23:03 -070029#include <utils/Timers.h>
Yiwei Zhang0102ad22018-05-02 17:37:17 -070030#include <utils/Trace.h>
31
32#include <algorithm>
Alec Mouri9519bf12019-11-15 16:54:44 -080033#include <chrono>
Yiwei Zhang0102ad22018-05-02 17:37:17 -070034
35namespace android {
36
Alec Mourifb571ea2019-01-24 18:42:10 -080037namespace impl {
38
Alec Mouri8e2f31b2020-01-16 22:04:35 +000039status_pull_atom_return_t TimeStats::pullGlobalAtomCallback(int32_t atom_tag,
40 pulled_stats_event_list* data,
41 void* cookie) {
42 impl::TimeStats* timeStats = reinterpret_cast<impl::TimeStats*>(cookie);
43 if (atom_tag != android::util::SURFACEFLINGER_STATS_GLOBAL_INFO) {
44 return STATS_PULL_SKIP;
45 }
46
47 std::lock_guard<std::mutex> lock(timeStats->mMutex);
48
49 const auto& stats = timeStats->mTimeStats;
50 if (stats.statsStart == 0) {
51 return STATS_PULL_SKIP;
52 }
53 timeStats->flushPowerTimeLocked();
54
55 struct stats_event* event = timeStats->mStatsDelegate->addStatsEventToPullData(data);
56 timeStats->mStatsDelegate->statsEventSetAtomId(event,
57 android::util::SURFACEFLINGER_STATS_GLOBAL_INFO);
58 timeStats->mStatsDelegate->statsEventWriteInt64(event, stats.totalFrames);
59 timeStats->mStatsDelegate->statsEventWriteInt64(event, stats.missedFrames);
60 timeStats->mStatsDelegate->statsEventWriteInt64(event, stats.clientCompositionFrames);
61 timeStats->mStatsDelegate->statsEventWriteInt64(event, stats.displayOnTime);
62 timeStats->mStatsDelegate->statsEventWriteInt64(event, stats.presentToPresent.totalTime());
63 timeStats->mStatsDelegate->statsEventBuild(event);
64 timeStats->clearGlobalLocked();
65
66 return STATS_PULL_SUCCESS;
67}
68
69TimeStats::TimeStats() : TimeStats(nullptr) {}
70
71TimeStats::TimeStats(std::unique_ptr<StatsEventDelegate> statsDelegate) {
72 if (statsDelegate != nullptr) {
73 mStatsDelegate = std::move(statsDelegate);
74 }
75}
76
77void TimeStats::onBootFinished() {
Alec Mourib3885ad2019-09-06 17:08:55 -070078 // Temporarily enable TimeStats by default. Telemetry is disabled while
79 // we move onto statsd, so TimeStats is currently not exercised at all
Alec Mouri8e2f31b2020-01-16 22:04:35 +000080 // during testing without enabling by default.
81 // TODO: remove this, as we should only be paying this overhead on devices
82 // where statsd exists.
Alec Mourib3885ad2019-09-06 17:08:55 -070083 enable();
84}
85
Dominik Laskowskic2867142019-01-21 11:33:38 -080086void TimeStats::parseArgs(bool asProto, const Vector<String16>& args, std::string& result) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -070087 ATRACE_CALL();
88
Yiwei Zhang0102ad22018-05-02 17:37:17 -070089 std::unordered_map<std::string, int32_t> argsMap;
Dominik Laskowskic2867142019-01-21 11:33:38 -080090 for (size_t index = 0; index < args.size(); ++index) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -070091 argsMap[std::string(String8(args[index]).c_str())] = index;
Yiwei Zhang0102ad22018-05-02 17:37:17 -070092 }
93
94 if (argsMap.count("-disable")) {
95 disable();
96 }
97
98 if (argsMap.count("-dump")) {
Yiwei Zhang8a4015c2018-05-08 16:03:47 -070099 std::optional<uint32_t> maxLayers = std::nullopt;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700100 auto iter = argsMap.find("-maxlayers");
101 if (iter != argsMap.end() && iter->second + 1 < static_cast<int32_t>(args.size())) {
Yiwei Zhang8a4015c2018-05-08 16:03:47 -0700102 int64_t value = strtol(String8(args[iter->second + 1]).c_str(), nullptr, 10);
103 value = std::clamp(value, int64_t(0), int64_t(UINT32_MAX));
104 maxLayers = static_cast<uint32_t>(value);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700105 }
106
Yiwei Zhang8a4015c2018-05-08 16:03:47 -0700107 dump(asProto, maxLayers, result);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700108 }
109
110 if (argsMap.count("-clear")) {
Alec Mouri8e2f31b2020-01-16 22:04:35 +0000111 clearAll();
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700112 }
113
114 if (argsMap.count("-enable")) {
115 enable();
116 }
117}
118
Yiwei Zhang7eb58b72019-04-22 19:00:02 -0700119std::string TimeStats::miniDump() {
120 ATRACE_CALL();
121
122 std::string result = "TimeStats miniDump:\n";
123 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhange926ab52019-08-14 15:16:00 -0700124 android::base::StringAppendF(&result, "Number of layers currently being tracked is %zu\n",
Yiwei Zhang7eb58b72019-04-22 19:00:02 -0700125 mTimeStatsTracker.size());
Yiwei Zhange926ab52019-08-14 15:16:00 -0700126 android::base::StringAppendF(&result, "Number of layers in the stats pool is %zu\n",
127 mTimeStats.stats.size());
Yiwei Zhang7eb58b72019-04-22 19:00:02 -0700128 return result;
129}
130
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700131void TimeStats::incrementTotalFrames() {
132 if (!mEnabled.load()) return;
133
134 ATRACE_CALL();
135
136 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhangdc224042018-10-18 15:34:00 -0700137 mTimeStats.totalFrames++;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700138}
139
Yiwei Zhang621f9d42018-05-07 10:40:55 -0700140void TimeStats::incrementMissedFrames() {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700141 if (!mEnabled.load()) return;
142
143 ATRACE_CALL();
144
145 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhangdc224042018-10-18 15:34:00 -0700146 mTimeStats.missedFrames++;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700147}
148
149void TimeStats::incrementClientCompositionFrames() {
150 if (!mEnabled.load()) return;
151
152 ATRACE_CALL();
153
154 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhangdc224042018-10-18 15:34:00 -0700155 mTimeStats.clientCompositionFrames++;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700156}
157
Vishnu Nair9b079a22020-01-21 14:36:08 -0800158void TimeStats::incrementClientCompositionReusedFrames() {
159 if (!mEnabled.load()) return;
160
161 ATRACE_CALL();
162
163 std::lock_guard<std::mutex> lock(mMutex);
164 mTimeStats.clientCompositionReusedFrames++;
165}
166
Alec Mouri9519bf12019-11-15 16:54:44 -0800167static int32_t msBetween(nsecs_t start, nsecs_t end) {
168 int64_t delta = std::chrono::duration_cast<std::chrono::milliseconds>(
169 std::chrono::nanoseconds(end - start))
170 .count();
171 delta = std::clamp(delta, int64_t(INT32_MIN), int64_t(INT32_MAX));
172 return static_cast<int32_t>(delta);
173}
174
175void TimeStats::recordFrameDuration(nsecs_t startTime, nsecs_t endTime) {
176 if (!mEnabled.load()) return;
177
178 std::lock_guard<std::mutex> lock(mMutex);
179 if (mPowerTime.powerMode == HWC_POWER_MODE_NORMAL) {
180 mTimeStats.frameDuration.insert(msBetween(startTime, endTime));
181 }
182}
183
Alec Mourie4034bb2019-11-19 12:45:54 -0800184void TimeStats::recordRenderEngineDuration(nsecs_t startTime, nsecs_t endTime) {
185 if (!mEnabled.load()) return;
186
187 std::lock_guard<std::mutex> lock(mMutex);
188 if (mGlobalRecord.renderEngineDurations.size() == MAX_NUM_TIME_RECORDS) {
189 ALOGE("RenderEngineTimes are already at its maximum size[%zu]", MAX_NUM_TIME_RECORDS);
190 mGlobalRecord.renderEngineDurations.pop_front();
191 }
192 mGlobalRecord.renderEngineDurations.push_back({startTime, endTime});
193}
194
195void TimeStats::recordRenderEngineDuration(nsecs_t startTime,
196 const std::shared_ptr<FenceTime>& endTime) {
197 if (!mEnabled.load()) return;
198
199 std::lock_guard<std::mutex> lock(mMutex);
200 if (mGlobalRecord.renderEngineDurations.size() == MAX_NUM_TIME_RECORDS) {
201 ALOGE("RenderEngineTimes are already at its maximum size[%zu]", MAX_NUM_TIME_RECORDS);
202 mGlobalRecord.renderEngineDurations.pop_front();
203 }
204 mGlobalRecord.renderEngineDurations.push_back({startTime, endTime});
205}
206
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800207bool TimeStats::recordReadyLocked(int32_t layerId, TimeRecord* timeRecord) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700208 if (!timeRecord->ready) {
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800209 ALOGV("[%d]-[%" PRIu64 "]-presentFence is still not received", layerId,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700210 timeRecord->frameTime.frameNumber);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700211 return false;
212 }
213
214 if (timeRecord->acquireFence != nullptr) {
215 if (timeRecord->acquireFence->getSignalTime() == Fence::SIGNAL_TIME_PENDING) {
216 return false;
217 }
218 if (timeRecord->acquireFence->getSignalTime() != Fence::SIGNAL_TIME_INVALID) {
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700219 timeRecord->frameTime.acquireTime = timeRecord->acquireFence->getSignalTime();
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700220 timeRecord->acquireFence = nullptr;
221 } else {
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800222 ALOGV("[%d]-[%" PRIu64 "]-acquireFence signal time is invalid", layerId,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700223 timeRecord->frameTime.frameNumber);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700224 }
225 }
226
227 if (timeRecord->presentFence != nullptr) {
228 if (timeRecord->presentFence->getSignalTime() == Fence::SIGNAL_TIME_PENDING) {
229 return false;
230 }
231 if (timeRecord->presentFence->getSignalTime() != Fence::SIGNAL_TIME_INVALID) {
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700232 timeRecord->frameTime.presentTime = timeRecord->presentFence->getSignalTime();
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700233 timeRecord->presentFence = nullptr;
234 } else {
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800235 ALOGV("[%d]-[%" PRIu64 "]-presentFence signal time invalid", layerId,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700236 timeRecord->frameTime.frameNumber);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700237 }
238 }
239
240 return true;
241}
242
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800243void TimeStats::flushAvailableRecordsToStatsLocked(int32_t layerId) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700244 ATRACE_CALL();
245
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800246 LayerRecord& layerRecord = mTimeStatsTracker[layerId];
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700247 TimeRecord& prevTimeRecord = layerRecord.prevTimeRecord;
Yiwei Zhangc5f2c452018-05-08 16:31:56 -0700248 std::deque<TimeRecord>& timeRecords = layerRecord.timeRecords;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700249 while (!timeRecords.empty()) {
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800250 if (!recordReadyLocked(layerId, &timeRecords[0])) break;
251 ALOGV("[%d]-[%" PRIu64 "]-presentFenceTime[%" PRId64 "]", layerId,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700252 timeRecords[0].frameTime.frameNumber, timeRecords[0].frameTime.presentTime);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700253
254 if (prevTimeRecord.ready) {
Yiwei Zhangeafa5cc2019-07-26 15:06:25 -0700255 const std::string& layerName = layerRecord.layerName;
Yiwei Zhangdc224042018-10-18 15:34:00 -0700256 if (!mTimeStats.stats.count(layerName)) {
257 mTimeStats.stats[layerName].layerName = layerName;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700258 }
Yiwei Zhangdc224042018-10-18 15:34:00 -0700259 TimeStatsHelper::TimeStatsLayer& timeStatsLayer = mTimeStats.stats[layerName];
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700260 timeStatsLayer.totalFrames++;
Yiwei Zhangeaeea062018-06-28 14:46:51 -0700261 timeStatsLayer.droppedFrames += layerRecord.droppedFrames;
262 layerRecord.droppedFrames = 0;
263
264 const int32_t postToAcquireMs = msBetween(timeRecords[0].frameTime.postTime,
265 timeRecords[0].frameTime.acquireTime);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800266 ALOGV("[%d]-[%" PRIu64 "]-post2acquire[%d]", layerId,
Yiwei Zhangeaeea062018-06-28 14:46:51 -0700267 timeRecords[0].frameTime.frameNumber, postToAcquireMs);
268 timeStatsLayer.deltas["post2acquire"].insert(postToAcquireMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700269
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700270 const int32_t postToPresentMs = msBetween(timeRecords[0].frameTime.postTime,
271 timeRecords[0].frameTime.presentTime);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800272 ALOGV("[%d]-[%" PRIu64 "]-post2present[%d]", layerId,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700273 timeRecords[0].frameTime.frameNumber, postToPresentMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700274 timeStatsLayer.deltas["post2present"].insert(postToPresentMs);
275
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700276 const int32_t acquireToPresentMs = msBetween(timeRecords[0].frameTime.acquireTime,
277 timeRecords[0].frameTime.presentTime);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800278 ALOGV("[%d]-[%" PRIu64 "]-acquire2present[%d]", layerId,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700279 timeRecords[0].frameTime.frameNumber, acquireToPresentMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700280 timeStatsLayer.deltas["acquire2present"].insert(acquireToPresentMs);
281
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700282 const int32_t latchToPresentMs = msBetween(timeRecords[0].frameTime.latchTime,
283 timeRecords[0].frameTime.presentTime);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800284 ALOGV("[%d]-[%" PRIu64 "]-latch2present[%d]", layerId,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700285 timeRecords[0].frameTime.frameNumber, latchToPresentMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700286 timeStatsLayer.deltas["latch2present"].insert(latchToPresentMs);
287
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700288 const int32_t desiredToPresentMs = msBetween(timeRecords[0].frameTime.desiredTime,
289 timeRecords[0].frameTime.presentTime);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800290 ALOGV("[%d]-[%" PRIu64 "]-desired2present[%d]", layerId,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700291 timeRecords[0].frameTime.frameNumber, desiredToPresentMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700292 timeStatsLayer.deltas["desired2present"].insert(desiredToPresentMs);
293
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700294 const int32_t presentToPresentMs = msBetween(prevTimeRecord.frameTime.presentTime,
295 timeRecords[0].frameTime.presentTime);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800296 ALOGV("[%d]-[%" PRIu64 "]-present2present[%d]", layerId,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700297 timeRecords[0].frameTime.frameNumber, presentToPresentMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700298 timeStatsLayer.deltas["present2present"].insert(presentToPresentMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700299 }
300 prevTimeRecord = timeRecords[0];
Yiwei Zhangc5f2c452018-05-08 16:31:56 -0700301 timeRecords.pop_front();
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700302 layerRecord.waitData--;
303 }
304}
305
Yiwei Zhang8bec7e82019-10-07 18:08:26 -0700306static constexpr const char* kPopupWindowPrefix = "PopupWindow";
307static const size_t kMinLenLayerName = std::strlen(kPopupWindowPrefix);
Yiwei Zhangbd408322018-10-15 18:31:53 -0700308
Yiwei Zhang8bec7e82019-10-07 18:08:26 -0700309// Avoid tracking the "PopupWindow:<random hash>#<number>" layers
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700310static bool layerNameIsValid(const std::string& layerName) {
Yiwei Zhang8bec7e82019-10-07 18:08:26 -0700311 return layerName.length() >= kMinLenLayerName &&
312 layerName.compare(0, kMinLenLayerName, kPopupWindowPrefix) != 0;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700313}
314
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800315void TimeStats::setPostTime(int32_t layerId, uint64_t frameNumber, const std::string& layerName,
Yiwei Zhang8e8fe522018-11-02 18:34:07 -0700316 nsecs_t postTime) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700317 if (!mEnabled.load()) return;
318
319 ATRACE_CALL();
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800320 ALOGV("[%d]-[%" PRIu64 "]-[%s]-PostTime[%" PRId64 "]", layerId, frameNumber, layerName.c_str(),
Yiwei Zhang8e8fe522018-11-02 18:34:07 -0700321 postTime);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700322
323 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhange926ab52019-08-14 15:16:00 -0700324 if (!mTimeStats.stats.count(layerName) && mTimeStats.stats.size() >= MAX_NUM_LAYER_STATS) {
325 return;
326 }
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800327 if (!mTimeStatsTracker.count(layerId) && mTimeStatsTracker.size() < MAX_NUM_LAYER_RECORDS &&
Yiwei Zhang7eb58b72019-04-22 19:00:02 -0700328 layerNameIsValid(layerName)) {
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800329 mTimeStatsTracker[layerId].layerName = layerName;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700330 }
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800331 if (!mTimeStatsTracker.count(layerId)) return;
332 LayerRecord& layerRecord = mTimeStatsTracker[layerId];
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700333 if (layerRecord.timeRecords.size() == MAX_NUM_TIME_RECORDS) {
Yiwei Zhangaf8ee942018-11-22 00:15:23 -0800334 ALOGE("[%d]-[%s]-timeRecords is at its maximum size[%zu]. Ignore this when unittesting.",
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800335 layerId, layerRecord.layerName.c_str(), MAX_NUM_TIME_RECORDS);
336 mTimeStatsTracker.erase(layerId);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700337 return;
338 }
339 // For most media content, the acquireFence is invalid because the buffer is
340 // ready at the queueBuffer stage. In this case, acquireTime should be given
341 // a default value as postTime.
342 TimeRecord timeRecord = {
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700343 .frameTime =
344 {
345 .frameNumber = frameNumber,
346 .postTime = postTime,
Yiwei Zhangaf8ee942018-11-22 00:15:23 -0800347 .latchTime = postTime,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700348 .acquireTime = postTime,
Yiwei Zhangaf8ee942018-11-22 00:15:23 -0800349 .desiredTime = postTime,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700350 },
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700351 };
352 layerRecord.timeRecords.push_back(timeRecord);
353 if (layerRecord.waitData < 0 ||
354 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
355 layerRecord.waitData = layerRecord.timeRecords.size() - 1;
356}
357
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800358void TimeStats::setLatchTime(int32_t layerId, uint64_t frameNumber, nsecs_t latchTime) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700359 if (!mEnabled.load()) return;
360
361 ATRACE_CALL();
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800362 ALOGV("[%d]-[%" PRIu64 "]-LatchTime[%" PRId64 "]", layerId, frameNumber, latchTime);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700363
364 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800365 if (!mTimeStatsTracker.count(layerId)) return;
366 LayerRecord& layerRecord = mTimeStatsTracker[layerId];
Yiwei Zhangcb7dd002019-04-16 11:03:01 -0700367 if (layerRecord.waitData < 0 ||
368 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
369 return;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700370 TimeRecord& timeRecord = layerRecord.timeRecords[layerRecord.waitData];
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700371 if (timeRecord.frameTime.frameNumber == frameNumber) {
372 timeRecord.frameTime.latchTime = latchTime;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700373 }
374}
375
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800376void TimeStats::setDesiredTime(int32_t layerId, uint64_t frameNumber, nsecs_t desiredTime) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700377 if (!mEnabled.load()) return;
378
379 ATRACE_CALL();
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800380 ALOGV("[%d]-[%" PRIu64 "]-DesiredTime[%" PRId64 "]", layerId, frameNumber, desiredTime);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700381
382 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800383 if (!mTimeStatsTracker.count(layerId)) return;
384 LayerRecord& layerRecord = mTimeStatsTracker[layerId];
Yiwei Zhangcb7dd002019-04-16 11:03:01 -0700385 if (layerRecord.waitData < 0 ||
386 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
387 return;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700388 TimeRecord& timeRecord = layerRecord.timeRecords[layerRecord.waitData];
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700389 if (timeRecord.frameTime.frameNumber == frameNumber) {
390 timeRecord.frameTime.desiredTime = desiredTime;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700391 }
392}
393
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800394void TimeStats::setAcquireTime(int32_t layerId, uint64_t frameNumber, nsecs_t acquireTime) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700395 if (!mEnabled.load()) return;
396
397 ATRACE_CALL();
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800398 ALOGV("[%d]-[%" PRIu64 "]-AcquireTime[%" PRId64 "]", layerId, frameNumber, acquireTime);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700399
400 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800401 if (!mTimeStatsTracker.count(layerId)) return;
402 LayerRecord& layerRecord = mTimeStatsTracker[layerId];
Yiwei Zhangcb7dd002019-04-16 11:03:01 -0700403 if (layerRecord.waitData < 0 ||
404 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
405 return;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700406 TimeRecord& timeRecord = layerRecord.timeRecords[layerRecord.waitData];
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700407 if (timeRecord.frameTime.frameNumber == frameNumber) {
408 timeRecord.frameTime.acquireTime = acquireTime;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700409 }
410}
411
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800412void TimeStats::setAcquireFence(int32_t layerId, uint64_t frameNumber,
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700413 const std::shared_ptr<FenceTime>& acquireFence) {
414 if (!mEnabled.load()) return;
415
416 ATRACE_CALL();
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800417 ALOGV("[%d]-[%" PRIu64 "]-AcquireFenceTime[%" PRId64 "]", layerId, frameNumber,
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700418 acquireFence->getSignalTime());
419
420 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800421 if (!mTimeStatsTracker.count(layerId)) return;
422 LayerRecord& layerRecord = mTimeStatsTracker[layerId];
Yiwei Zhangcb7dd002019-04-16 11:03:01 -0700423 if (layerRecord.waitData < 0 ||
424 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
425 return;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700426 TimeRecord& timeRecord = layerRecord.timeRecords[layerRecord.waitData];
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700427 if (timeRecord.frameTime.frameNumber == frameNumber) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700428 timeRecord.acquireFence = acquireFence;
429 }
430}
431
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800432void TimeStats::setPresentTime(int32_t layerId, uint64_t frameNumber, nsecs_t presentTime) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700433 if (!mEnabled.load()) return;
434
435 ATRACE_CALL();
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800436 ALOGV("[%d]-[%" PRIu64 "]-PresentTime[%" PRId64 "]", layerId, frameNumber, presentTime);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700437
438 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800439 if (!mTimeStatsTracker.count(layerId)) return;
440 LayerRecord& layerRecord = mTimeStatsTracker[layerId];
Yiwei Zhangcb7dd002019-04-16 11:03:01 -0700441 if (layerRecord.waitData < 0 ||
442 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
443 return;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700444 TimeRecord& timeRecord = layerRecord.timeRecords[layerRecord.waitData];
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700445 if (timeRecord.frameTime.frameNumber == frameNumber) {
446 timeRecord.frameTime.presentTime = presentTime;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700447 timeRecord.ready = true;
448 layerRecord.waitData++;
449 }
450
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800451 flushAvailableRecordsToStatsLocked(layerId);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700452}
453
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800454void TimeStats::setPresentFence(int32_t layerId, uint64_t frameNumber,
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700455 const std::shared_ptr<FenceTime>& presentFence) {
456 if (!mEnabled.load()) return;
457
458 ATRACE_CALL();
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800459 ALOGV("[%d]-[%" PRIu64 "]-PresentFenceTime[%" PRId64 "]", layerId, frameNumber,
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700460 presentFence->getSignalTime());
461
462 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800463 if (!mTimeStatsTracker.count(layerId)) return;
464 LayerRecord& layerRecord = mTimeStatsTracker[layerId];
Yiwei Zhangcb7dd002019-04-16 11:03:01 -0700465 if (layerRecord.waitData < 0 ||
466 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
467 return;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700468 TimeRecord& timeRecord = layerRecord.timeRecords[layerRecord.waitData];
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700469 if (timeRecord.frameTime.frameNumber == frameNumber) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700470 timeRecord.presentFence = presentFence;
471 timeRecord.ready = true;
472 layerRecord.waitData++;
473 }
474
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800475 flushAvailableRecordsToStatsLocked(layerId);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700476}
477
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800478void TimeStats::onDestroy(int32_t layerId) {
Yiwei Zhangdc224042018-10-18 15:34:00 -0700479 ATRACE_CALL();
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800480 ALOGV("[%d]-onDestroy", layerId);
Mikael Pessa90092f42019-08-26 17:22:04 -0700481 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800482 mTimeStatsTracker.erase(layerId);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700483}
484
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800485void TimeStats::removeTimeRecord(int32_t layerId, uint64_t frameNumber) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700486 if (!mEnabled.load()) return;
487
488 ATRACE_CALL();
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800489 ALOGV("[%d]-[%" PRIu64 "]-removeTimeRecord", layerId, frameNumber);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700490
491 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800492 if (!mTimeStatsTracker.count(layerId)) return;
493 LayerRecord& layerRecord = mTimeStatsTracker[layerId];
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700494 size_t removeAt = 0;
495 for (const TimeRecord& record : layerRecord.timeRecords) {
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700496 if (record.frameTime.frameNumber == frameNumber) break;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700497 removeAt++;
498 }
499 if (removeAt == layerRecord.timeRecords.size()) return;
500 layerRecord.timeRecords.erase(layerRecord.timeRecords.begin() + removeAt);
501 if (layerRecord.waitData > static_cast<int32_t>(removeAt)) {
Yiwei Zhangeaeea062018-06-28 14:46:51 -0700502 layerRecord.waitData--;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700503 }
Yiwei Zhangeaeea062018-06-28 14:46:51 -0700504 layerRecord.droppedFrames++;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700505}
506
Yiwei Zhang3a226d22018-10-16 09:23:03 -0700507void TimeStats::flushPowerTimeLocked() {
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700508 if (!mEnabled.load()) return;
509
Yiwei Zhang3a226d22018-10-16 09:23:03 -0700510 nsecs_t curTime = systemTime();
511 // elapsedTime is in milliseconds.
512 int64_t elapsedTime = (curTime - mPowerTime.prevTime) / 1000000;
513
514 switch (mPowerTime.powerMode) {
515 case HWC_POWER_MODE_NORMAL:
516 mTimeStats.displayOnTime += elapsedTime;
517 break;
518 case HWC_POWER_MODE_OFF:
519 case HWC_POWER_MODE_DOZE:
520 case HWC_POWER_MODE_DOZE_SUSPEND:
521 default:
522 break;
523 }
524
525 mPowerTime.prevTime = curTime;
526}
527
528void TimeStats::setPowerMode(int32_t powerMode) {
529 if (!mEnabled.load()) {
530 std::lock_guard<std::mutex> lock(mMutex);
531 mPowerTime.powerMode = powerMode;
532 return;
533 }
534
535 std::lock_guard<std::mutex> lock(mMutex);
536 if (powerMode == mPowerTime.powerMode) return;
537
538 flushPowerTimeLocked();
539 mPowerTime.powerMode = powerMode;
540}
541
Alec Mourifb571ea2019-01-24 18:42:10 -0800542void TimeStats::recordRefreshRate(uint32_t fps, nsecs_t duration) {
543 std::lock_guard<std::mutex> lock(mMutex);
544 if (mTimeStats.refreshRateStats.count(fps)) {
545 mTimeStats.refreshRateStats[fps] += duration;
546 } else {
547 mTimeStats.refreshRateStats.insert({fps, duration});
548 }
549}
550
Yiwei Zhangce6ebc02018-10-20 12:42:38 -0700551void TimeStats::flushAvailableGlobalRecordsToStatsLocked() {
552 ATRACE_CALL();
553
554 while (!mGlobalRecord.presentFences.empty()) {
555 const nsecs_t curPresentTime = mGlobalRecord.presentFences.front()->getSignalTime();
556 if (curPresentTime == Fence::SIGNAL_TIME_PENDING) break;
557
558 if (curPresentTime == Fence::SIGNAL_TIME_INVALID) {
559 ALOGE("GlobalPresentFence is invalid!");
560 mGlobalRecord.prevPresentTime = 0;
561 mGlobalRecord.presentFences.pop_front();
562 continue;
563 }
564
565 ALOGV("GlobalPresentFenceTime[%" PRId64 "]",
566 mGlobalRecord.presentFences.front()->getSignalTime());
567
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700568 if (mGlobalRecord.prevPresentTime != 0) {
569 const int32_t presentToPresentMs =
570 msBetween(mGlobalRecord.prevPresentTime, curPresentTime);
571 ALOGV("Global present2present[%d] prev[%" PRId64 "] curr[%" PRId64 "]",
572 presentToPresentMs, mGlobalRecord.prevPresentTime, curPresentTime);
573 mTimeStats.presentToPresent.insert(presentToPresentMs);
574 }
Yiwei Zhangce6ebc02018-10-20 12:42:38 -0700575
Yiwei Zhangce6ebc02018-10-20 12:42:38 -0700576 mGlobalRecord.prevPresentTime = curPresentTime;
577 mGlobalRecord.presentFences.pop_front();
578 }
Alec Mourie4034bb2019-11-19 12:45:54 -0800579 while (!mGlobalRecord.renderEngineDurations.empty()) {
580 const auto duration = mGlobalRecord.renderEngineDurations.front();
581 const auto& endTime = duration.endTime;
582
583 nsecs_t endNs = -1;
584
585 if (auto val = std::get_if<nsecs_t>(&endTime)) {
586 endNs = *val;
587 } else {
588 endNs = std::get<std::shared_ptr<FenceTime>>(endTime)->getSignalTime();
589 }
590
591 if (endNs == Fence::SIGNAL_TIME_PENDING) break;
592
593 if (endNs < 0) {
594 ALOGE("RenderEngineTiming is invalid!");
595 mGlobalRecord.renderEngineDurations.pop_front();
596 continue;
597 }
598
599 const int32_t renderEngineMs = msBetween(duration.startTime, endNs);
600 mTimeStats.renderEngineTiming.insert(renderEngineMs);
601
602 mGlobalRecord.renderEngineDurations.pop_front();
603 }
Yiwei Zhangce6ebc02018-10-20 12:42:38 -0700604}
605
606void TimeStats::setPresentFenceGlobal(const std::shared_ptr<FenceTime>& presentFence) {
607 if (!mEnabled.load()) return;
608
609 ATRACE_CALL();
610 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700611 if (presentFence == nullptr || !presentFence->isValid()) {
612 mGlobalRecord.prevPresentTime = 0;
613 return;
614 }
615
616 if (mPowerTime.powerMode != HWC_POWER_MODE_NORMAL) {
617 // Try flushing the last present fence on HWC_POWER_MODE_NORMAL.
618 flushAvailableGlobalRecordsToStatsLocked();
619 mGlobalRecord.presentFences.clear();
Yiwei Zhangce6ebc02018-10-20 12:42:38 -0700620 mGlobalRecord.prevPresentTime = 0;
621 return;
622 }
623
624 if (mGlobalRecord.presentFences.size() == MAX_NUM_TIME_RECORDS) {
625 // The front presentFence must be trapped in pending status in this
626 // case. Try dequeuing the front one to recover.
627 ALOGE("GlobalPresentFences is already at its maximum size[%zu]", MAX_NUM_TIME_RECORDS);
628 mGlobalRecord.prevPresentTime = 0;
629 mGlobalRecord.presentFences.pop_front();
630 }
631
632 mGlobalRecord.presentFences.emplace_back(presentFence);
633 flushAvailableGlobalRecordsToStatsLocked();
634}
635
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700636void TimeStats::enable() {
637 if (mEnabled.load()) return;
638
639 ATRACE_CALL();
640
641 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700642 mEnabled.store(true);
Yiwei Zhangdc224042018-10-18 15:34:00 -0700643 mTimeStats.statsStart = static_cast<int64_t>(std::time(0));
Yiwei Zhang3a226d22018-10-16 09:23:03 -0700644 mPowerTime.prevTime = systemTime();
Alec Mouri8e2f31b2020-01-16 22:04:35 +0000645 mStatsDelegate->registerStatsPullAtomCallback(android::util::SURFACEFLINGER_STATS_GLOBAL_INFO,
646 TimeStats::pullGlobalAtomCallback, nullptr, this);
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700647 ALOGD("Enabled");
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700648}
649
650void TimeStats::disable() {
651 if (!mEnabled.load()) return;
652
653 ATRACE_CALL();
654
655 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700656 flushPowerTimeLocked();
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700657 mEnabled.store(false);
Yiwei Zhangdc224042018-10-18 15:34:00 -0700658 mTimeStats.statsEnd = static_cast<int64_t>(std::time(0));
Alec Mouri8e2f31b2020-01-16 22:04:35 +0000659 mStatsDelegate->unregisterStatsPullAtomCallback(
660 android::util::SURFACEFLINGER_STATS_GLOBAL_INFO);
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700661 ALOGD("Disabled");
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700662}
663
Alec Mouri8e2f31b2020-01-16 22:04:35 +0000664void TimeStats::clearAll() {
665 std::lock_guard<std::mutex> lock(mMutex);
666 clearGlobalLocked();
667 clearLayersLocked();
668}
669
670void TimeStats::clearGlobalLocked() {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700671 ATRACE_CALL();
672
Yiwei Zhangdc224042018-10-18 15:34:00 -0700673 mTimeStats.statsStart = (mEnabled.load() ? static_cast<int64_t>(std::time(0)) : 0);
674 mTimeStats.statsEnd = 0;
675 mTimeStats.totalFrames = 0;
676 mTimeStats.missedFrames = 0;
677 mTimeStats.clientCompositionFrames = 0;
Vishnu Nair9b079a22020-01-21 14:36:08 -0800678 mTimeStats.clientCompositionReusedFrames = 0;
Yiwei Zhang3a226d22018-10-16 09:23:03 -0700679 mTimeStats.displayOnTime = 0;
Yiwei Zhangce6ebc02018-10-20 12:42:38 -0700680 mTimeStats.presentToPresent.hist.clear();
Alec Mouri31ac64a2020-01-09 09:26:22 -0800681 mTimeStats.frameDuration.hist.clear();
682 mTimeStats.renderEngineTiming.hist.clear();
Alec Mourifb571ea2019-01-24 18:42:10 -0800683 mTimeStats.refreshRateStats.clear();
Yiwei Zhang3a226d22018-10-16 09:23:03 -0700684 mPowerTime.prevTime = systemTime();
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700685 mGlobalRecord.prevPresentTime = 0;
686 mGlobalRecord.presentFences.clear();
Alec Mouri8e2f31b2020-01-16 22:04:35 +0000687 ALOGD("Cleared global stats");
688}
689
690void TimeStats::clearLayersLocked() {
691 ATRACE_CALL();
692
693 mTimeStatsTracker.clear();
694 mTimeStats.stats.clear();
695 ALOGD("Cleared layer stats");
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700696}
697
698bool TimeStats::isEnabled() {
699 return mEnabled.load();
700}
701
Yiwei Zhang5434a782018-12-05 18:06:32 -0800702void TimeStats::dump(bool asProto, std::optional<uint32_t> maxLayers, std::string& result) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700703 ATRACE_CALL();
704
705 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhangdc224042018-10-18 15:34:00 -0700706 if (mTimeStats.statsStart == 0) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700707 return;
708 }
709
Yiwei Zhangdc224042018-10-18 15:34:00 -0700710 mTimeStats.statsEnd = static_cast<int64_t>(std::time(0));
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700711
Yiwei Zhang3a226d22018-10-16 09:23:03 -0700712 flushPowerTimeLocked();
713
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700714 if (asProto) {
Yiwei Zhang8a4015c2018-05-08 16:03:47 -0700715 ALOGD("Dumping TimeStats as proto");
Yiwei Zhangdc224042018-10-18 15:34:00 -0700716 SFTimeStatsGlobalProto timeStatsProto = mTimeStats.toProto(maxLayers);
Dominik Laskowski46470112019-08-02 13:13:11 -0700717 result.append(timeStatsProto.SerializeAsString());
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700718 } else {
Yiwei Zhang8a4015c2018-05-08 16:03:47 -0700719 ALOGD("Dumping TimeStats as text");
Yiwei Zhang5434a782018-12-05 18:06:32 -0800720 result.append(mTimeStats.toString(maxLayers));
Yiwei Zhang8a4015c2018-05-08 16:03:47 -0700721 result.append("\n");
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700722 }
723}
724
Alec Mourifb571ea2019-01-24 18:42:10 -0800725} // namespace impl
726
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700727} // namespace android
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -0800728
729// TODO(b/129481165): remove the #pragma below and fix conversion issues
730#pragma clang diagnostic pop // ignored "-Wconversion"