blob: b66e4cfe4f770ce45df7319df35b286cf4bf210d [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 */
16#undef LOG_TAG
17#define LOG_TAG "TimeStats"
18#define ATRACE_TAG ATRACE_TAG_GRAPHICS
19
20#include "TimeStats.h"
21
22#include <android-base/stringprintf.h>
23
24#include <log/log.h>
25
26#include <utils/String8.h>
Yiwei Zhang3a226d22018-10-16 09:23:03 -070027#include <utils/Timers.h>
Yiwei Zhang0102ad22018-05-02 17:37:17 -070028#include <utils/Trace.h>
29
30#include <algorithm>
31#include <regex>
32
Mikael Pessa2e1608f2019-07-19 11:25:35 -070033PERFETTO_DEFINE_DATA_SOURCE_STATIC_MEMBERS(android::impl::TimeStats::TimeStatsDataSource);
34
Yiwei Zhang0102ad22018-05-02 17:37:17 -070035namespace android {
36
Alec Mourifb571ea2019-01-24 18:42:10 -080037namespace impl {
38
Mikael Pessa2e1608f2019-07-19 11:25:35 -070039void TimeStats::initializeTracing() {
40 perfetto::TracingInitArgs args;
41 args.backends = perfetto::kSystemBackend;
42 perfetto::Tracing::Initialize(args);
43 registerTracingDataSource();
44}
45
46void TimeStats::registerTracingDataSource() {
47 perfetto::DataSourceDescriptor dsd;
48 dsd.set_name(kTimeStatsDataSource);
49 TimeStatsDataSource::Register(dsd);
50}
51
52void TimeStats::traceNewLayer(int32_t layerID, const std::string& layerName) {
53 TimeStatsDataSource::Trace([this, layerID, &layerName](TimeStatsDataSource::TraceContext) {
54 if (mTraceTracker.find(layerID) == mTraceTracker.end()) {
55 std::lock_guard<std::mutex> lock(mTraceMutex);
56 mTraceTracker[layerID].layerName = layerName;
57 }
58 });
59}
60
61void TimeStats::traceTimestamp(int32_t layerID, uint64_t bufferID, uint64_t frameNumber,
62 nsecs_t timestamp, FrameEvent::BufferEventType type,
63 nsecs_t duration) {
64 TimeStatsDataSource::Trace([this, layerID, bufferID, frameNumber, timestamp, type,
65 duration](TimeStatsDataSource::TraceContext ctx) {
66 std::lock_guard<std::mutex> lock(mTraceMutex);
67 if (mTraceTracker.find(layerID) == mTraceTracker.end()) {
68 return;
69 }
70
71 // Handle any pending fences for this buffer.
72 tracePendingFencesLocked(ctx, layerID, bufferID);
73
74 // Complete current trace.
75 traceLocked(ctx, layerID, bufferID, frameNumber, timestamp, type, duration);
76 });
77}
78
79void TimeStats::traceFence(int32_t layerID, uint64_t bufferID, uint64_t frameNumber,
80 const std::shared_ptr<FenceTime>& fence,
81 FrameEvent::BufferEventType type, nsecs_t startTime) {
82 TimeStatsDataSource::Trace([this, layerID, bufferID, frameNumber, &fence, type,
83 startTime](TimeStatsDataSource::TraceContext ctx) {
84 const nsecs_t signalTime = fence->getSignalTime();
85 if (signalTime != Fence::SIGNAL_TIME_INVALID) {
86 std::lock_guard<std::mutex> lock(mTraceMutex);
87 if (mTraceTracker.find(layerID) == mTraceTracker.end()) {
88 return;
89 }
90
91 // Handle any pending fences for this buffer.
92 tracePendingFencesLocked(ctx, layerID, bufferID);
93
94 if (signalTime != Fence::SIGNAL_TIME_PENDING) {
95 traceSpanLocked(ctx, layerID, bufferID, frameNumber, type, startTime, signalTime);
96 } else {
97 mTraceTracker[layerID].pendingFences[bufferID].push_back(
98 {.frameNumber = frameNumber,
99 .type = type,
100 .fence = fence,
101 .startTime = startTime});
102 }
103 }
104 });
105}
106
107void TimeStats::tracePendingFencesLocked(TimeStatsDataSource::TraceContext& ctx, int32_t layerID,
108 uint64_t bufferID) {
109 if (mTraceTracker[layerID].pendingFences.count(bufferID)) {
110 auto& pendingFences = mTraceTracker[layerID].pendingFences[bufferID];
111 for (size_t i = 0; i < pendingFences.size(); ++i) {
112 auto& pendingFence = pendingFences[i];
113
114 nsecs_t signalTime = Fence::SIGNAL_TIME_INVALID;
115 if (pendingFence.fence && pendingFence.fence->isValid()) {
116 signalTime = pendingFence.fence->getSignalTime();
117 if (signalTime == Fence::SIGNAL_TIME_PENDING) {
118 continue;
119 }
120 }
121
122 if (signalTime != Fence::SIGNAL_TIME_INVALID &&
123 systemTime() - signalTime < kFenceSignallingDeadline) {
124 traceSpanLocked(ctx, layerID, bufferID, pendingFence.frameNumber, pendingFence.type,
125 pendingFence.startTime, signalTime);
126 }
127
128 pendingFences.erase(pendingFences.begin() + i);
129 --i;
130 }
131 }
132}
133
134void TimeStats::traceLocked(TimeStatsDataSource::TraceContext& ctx, int32_t layerID,
135 uint64_t bufferID, uint64_t frameNumber, nsecs_t timestamp,
136 FrameEvent::BufferEventType type, nsecs_t duration) {
137 auto packet = ctx.NewTracePacket();
138 packet->set_timestamp(timestamp);
139 auto* event = packet->set_graphics_frame_event()->set_buffer_event();
140 event->set_buffer_id(static_cast<uint32_t>(bufferID));
141 event->set_frame_number(frameNumber);
142 event->set_type(type);
143
144 if (mTraceTracker.find(layerID) != mTraceTracker.end() &&
145 !mTraceTracker[layerID].layerName.empty()) {
146 const std::string& layerName = mTraceTracker[layerID].layerName;
147 event->set_layer_name(layerName.c_str(), layerName.size());
148 }
149
150 if (duration > 0) {
151 event->set_duration_ns(duration);
152 }
153}
154
155void TimeStats::traceSpanLocked(TimeStatsDataSource::TraceContext& ctx, int32_t layerID,
156 uint64_t bufferID, uint64_t frameNumber,
157 FrameEvent::BufferEventType type, nsecs_t startTime,
158 nsecs_t endTime) {
159 nsecs_t timestamp = endTime;
160 nsecs_t duration = 0;
161 if (startTime > 0 && startTime < endTime) {
162 timestamp = startTime;
163 duration = endTime - startTime;
164 }
165 traceLocked(ctx, layerID, bufferID, frameNumber, timestamp, type, duration);
166}
167
Dominik Laskowskic2867142019-01-21 11:33:38 -0800168void TimeStats::parseArgs(bool asProto, const Vector<String16>& args, std::string& result) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700169 ATRACE_CALL();
170
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700171 std::unordered_map<std::string, int32_t> argsMap;
Dominik Laskowskic2867142019-01-21 11:33:38 -0800172 for (size_t index = 0; index < args.size(); ++index) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700173 argsMap[std::string(String8(args[index]).c_str())] = index;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700174 }
175
176 if (argsMap.count("-disable")) {
177 disable();
178 }
179
180 if (argsMap.count("-dump")) {
Yiwei Zhang8a4015c2018-05-08 16:03:47 -0700181 std::optional<uint32_t> maxLayers = std::nullopt;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700182 auto iter = argsMap.find("-maxlayers");
183 if (iter != argsMap.end() && iter->second + 1 < static_cast<int32_t>(args.size())) {
Yiwei Zhang8a4015c2018-05-08 16:03:47 -0700184 int64_t value = strtol(String8(args[iter->second + 1]).c_str(), nullptr, 10);
185 value = std::clamp(value, int64_t(0), int64_t(UINT32_MAX));
186 maxLayers = static_cast<uint32_t>(value);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700187 }
188
Yiwei Zhang8a4015c2018-05-08 16:03:47 -0700189 dump(asProto, maxLayers, result);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700190 }
191
192 if (argsMap.count("-clear")) {
193 clear();
194 }
195
196 if (argsMap.count("-enable")) {
197 enable();
198 }
199}
200
Yiwei Zhang7eb58b72019-04-22 19:00:02 -0700201std::string TimeStats::miniDump() {
202 ATRACE_CALL();
203
204 std::string result = "TimeStats miniDump:\n";
205 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhange926ab52019-08-14 15:16:00 -0700206 android::base::StringAppendF(&result, "Number of layers currently being tracked is %zu\n",
Yiwei Zhang7eb58b72019-04-22 19:00:02 -0700207 mTimeStatsTracker.size());
Yiwei Zhange926ab52019-08-14 15:16:00 -0700208 android::base::StringAppendF(&result, "Number of layers in the stats pool is %zu\n",
209 mTimeStats.stats.size());
Mikael Pessa2e1608f2019-07-19 11:25:35 -0700210 android::base::StringAppendF(&result, "Number of layers currently being traced is %zu\n",
211 mTraceTracker.size());
Yiwei Zhang7eb58b72019-04-22 19:00:02 -0700212 return result;
213}
214
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700215void TimeStats::incrementTotalFrames() {
216 if (!mEnabled.load()) return;
217
218 ATRACE_CALL();
219
220 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhangdc224042018-10-18 15:34:00 -0700221 mTimeStats.totalFrames++;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700222}
223
Yiwei Zhang621f9d42018-05-07 10:40:55 -0700224void TimeStats::incrementMissedFrames() {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700225 if (!mEnabled.load()) return;
226
227 ATRACE_CALL();
228
229 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhangdc224042018-10-18 15:34:00 -0700230 mTimeStats.missedFrames++;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700231}
232
233void TimeStats::incrementClientCompositionFrames() {
234 if (!mEnabled.load()) return;
235
236 ATRACE_CALL();
237
238 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhangdc224042018-10-18 15:34:00 -0700239 mTimeStats.clientCompositionFrames++;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700240}
241
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700242bool TimeStats::recordReadyLocked(int32_t layerID, TimeRecord* timeRecord) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700243 if (!timeRecord->ready) {
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700244 ALOGV("[%d]-[%" PRIu64 "]-presentFence is still not received", layerID,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700245 timeRecord->frameTime.frameNumber);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700246 return false;
247 }
248
249 if (timeRecord->acquireFence != nullptr) {
250 if (timeRecord->acquireFence->getSignalTime() == Fence::SIGNAL_TIME_PENDING) {
251 return false;
252 }
253 if (timeRecord->acquireFence->getSignalTime() != Fence::SIGNAL_TIME_INVALID) {
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700254 timeRecord->frameTime.acquireTime = timeRecord->acquireFence->getSignalTime();
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700255 timeRecord->acquireFence = nullptr;
256 } else {
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700257 ALOGV("[%d]-[%" PRIu64 "]-acquireFence signal time is invalid", layerID,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700258 timeRecord->frameTime.frameNumber);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700259 }
260 }
261
262 if (timeRecord->presentFence != nullptr) {
263 if (timeRecord->presentFence->getSignalTime() == Fence::SIGNAL_TIME_PENDING) {
264 return false;
265 }
266 if (timeRecord->presentFence->getSignalTime() != Fence::SIGNAL_TIME_INVALID) {
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700267 timeRecord->frameTime.presentTime = timeRecord->presentFence->getSignalTime();
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700268 timeRecord->presentFence = nullptr;
269 } else {
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700270 ALOGV("[%d]-[%" PRIu64 "]-presentFence signal time invalid", layerID,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700271 timeRecord->frameTime.frameNumber);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700272 }
273 }
274
275 return true;
276}
277
278static int32_t msBetween(nsecs_t start, nsecs_t end) {
279 int64_t delta = (end - start) / 1000000;
280 delta = std::clamp(delta, int64_t(INT32_MIN), int64_t(INT32_MAX));
281 return static_cast<int32_t>(delta);
282}
283
Yiwei Zhangbd408322018-10-15 18:31:53 -0700284// This regular expression captures the following for instance:
285// StatusBar in StatusBar#0
286// com.appname in com.appname/com.appname.activity#0
287// com.appname in SurfaceView - com.appname/com.appname.activity#0
288static const std::regex packageNameRegex("(?:SurfaceView[-\\s\\t]+)?([^/]+).*#\\d+");
289
Yiwei Zhang8a4015c2018-05-08 16:03:47 -0700290static std::string getPackageName(const std::string& layerName) {
Yiwei Zhang8a4015c2018-05-08 16:03:47 -0700291 std::smatch match;
Yiwei Zhangbd408322018-10-15 18:31:53 -0700292 if (std::regex_match(layerName.begin(), layerName.end(), match, packageNameRegex)) {
Yiwei Zhang8a4015c2018-05-08 16:03:47 -0700293 // There must be a match for group 1 otherwise the whole string is not
294 // matched and the above will return false
295 return match[1];
296 }
297 return "";
298}
299
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700300void TimeStats::flushAvailableRecordsToStatsLocked(int32_t layerID) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700301 ATRACE_CALL();
302
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700303 LayerRecord& layerRecord = mTimeStatsTracker[layerID];
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700304 TimeRecord& prevTimeRecord = layerRecord.prevTimeRecord;
Yiwei Zhangc5f2c452018-05-08 16:31:56 -0700305 std::deque<TimeRecord>& timeRecords = layerRecord.timeRecords;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700306 while (!timeRecords.empty()) {
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700307 if (!recordReadyLocked(layerID, &timeRecords[0])) break;
308 ALOGV("[%d]-[%" PRIu64 "]-presentFenceTime[%" PRId64 "]", layerID,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700309 timeRecords[0].frameTime.frameNumber, timeRecords[0].frameTime.presentTime);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700310
311 if (prevTimeRecord.ready) {
Yiwei Zhangeafa5cc2019-07-26 15:06:25 -0700312 const std::string& layerName = layerRecord.layerName;
Yiwei Zhangdc224042018-10-18 15:34:00 -0700313 if (!mTimeStats.stats.count(layerName)) {
314 mTimeStats.stats[layerName].layerName = layerName;
315 mTimeStats.stats[layerName].packageName = getPackageName(layerName);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700316 }
Yiwei Zhangdc224042018-10-18 15:34:00 -0700317 TimeStatsHelper::TimeStatsLayer& timeStatsLayer = mTimeStats.stats[layerName];
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700318 timeStatsLayer.totalFrames++;
Yiwei Zhangeaeea062018-06-28 14:46:51 -0700319 timeStatsLayer.droppedFrames += layerRecord.droppedFrames;
320 layerRecord.droppedFrames = 0;
321
322 const int32_t postToAcquireMs = msBetween(timeRecords[0].frameTime.postTime,
323 timeRecords[0].frameTime.acquireTime);
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700324 ALOGV("[%d]-[%" PRIu64 "]-post2acquire[%d]", layerID,
Yiwei Zhangeaeea062018-06-28 14:46:51 -0700325 timeRecords[0].frameTime.frameNumber, postToAcquireMs);
326 timeStatsLayer.deltas["post2acquire"].insert(postToAcquireMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700327
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700328 const int32_t postToPresentMs = msBetween(timeRecords[0].frameTime.postTime,
329 timeRecords[0].frameTime.presentTime);
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700330 ALOGV("[%d]-[%" PRIu64 "]-post2present[%d]", layerID,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700331 timeRecords[0].frameTime.frameNumber, postToPresentMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700332 timeStatsLayer.deltas["post2present"].insert(postToPresentMs);
333
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700334 const int32_t acquireToPresentMs = msBetween(timeRecords[0].frameTime.acquireTime,
335 timeRecords[0].frameTime.presentTime);
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700336 ALOGV("[%d]-[%" PRIu64 "]-acquire2present[%d]", layerID,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700337 timeRecords[0].frameTime.frameNumber, acquireToPresentMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700338 timeStatsLayer.deltas["acquire2present"].insert(acquireToPresentMs);
339
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700340 const int32_t latchToPresentMs = msBetween(timeRecords[0].frameTime.latchTime,
341 timeRecords[0].frameTime.presentTime);
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700342 ALOGV("[%d]-[%" PRIu64 "]-latch2present[%d]", layerID,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700343 timeRecords[0].frameTime.frameNumber, latchToPresentMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700344 timeStatsLayer.deltas["latch2present"].insert(latchToPresentMs);
345
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700346 const int32_t desiredToPresentMs = msBetween(timeRecords[0].frameTime.desiredTime,
347 timeRecords[0].frameTime.presentTime);
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700348 ALOGV("[%d]-[%" PRIu64 "]-desired2present[%d]", layerID,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700349 timeRecords[0].frameTime.frameNumber, desiredToPresentMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700350 timeStatsLayer.deltas["desired2present"].insert(desiredToPresentMs);
351
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700352 const int32_t presentToPresentMs = msBetween(prevTimeRecord.frameTime.presentTime,
353 timeRecords[0].frameTime.presentTime);
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700354 ALOGV("[%d]-[%" PRIu64 "]-present2present[%d]", layerID,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700355 timeRecords[0].frameTime.frameNumber, presentToPresentMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700356 timeStatsLayer.deltas["present2present"].insert(presentToPresentMs);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700357 }
358 prevTimeRecord = timeRecords[0];
Yiwei Zhangc5f2c452018-05-08 16:31:56 -0700359 timeRecords.pop_front();
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700360 layerRecord.waitData--;
361 }
362}
363
Yiwei Zhangbd408322018-10-15 18:31:53 -0700364// This regular expression captures the following layer names for instance:
365// 1) StatusBat#0
366// 2) NavigationBar#1
367// 3) co(m).*#0
368// 4) SurfaceView - co(m).*#0
369// Using [-\\s\t]+ for the conjunction part between SurfaceView and co(m).*
370// is a bit more robust in case there's a slight change.
371// The layer name would only consist of . / $ _ 0-9 a-z A-Z in most cases.
372static const std::regex layerNameRegex(
373 "(((SurfaceView[-\\s\\t]+)?com?\\.[./$\\w]+)|((Status|Navigation)Bar))#\\d+");
374
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700375static bool layerNameIsValid(const std::string& layerName) {
Yiwei Zhangbd408322018-10-15 18:31:53 -0700376 return std::regex_match(layerName.begin(), layerName.end(), layerNameRegex);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700377}
378
Yiwei Zhang8e8fe522018-11-02 18:34:07 -0700379void TimeStats::setPostTime(int32_t layerID, uint64_t frameNumber, const std::string& layerName,
380 nsecs_t postTime) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700381 if (!mEnabled.load()) return;
382
383 ATRACE_CALL();
Yiwei Zhang8e8fe522018-11-02 18:34:07 -0700384 ALOGV("[%d]-[%" PRIu64 "]-[%s]-PostTime[%" PRId64 "]", layerID, frameNumber, layerName.c_str(),
385 postTime);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700386
387 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhange926ab52019-08-14 15:16:00 -0700388 if (!mTimeStats.stats.count(layerName) && mTimeStats.stats.size() >= MAX_NUM_LAYER_STATS) {
389 return;
390 }
Yiwei Zhang7eb58b72019-04-22 19:00:02 -0700391 if (!mTimeStatsTracker.count(layerID) && mTimeStatsTracker.size() < MAX_NUM_LAYER_RECORDS &&
392 layerNameIsValid(layerName)) {
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700393 mTimeStatsTracker[layerID].layerName = layerName;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700394 }
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700395 if (!mTimeStatsTracker.count(layerID)) return;
396 LayerRecord& layerRecord = mTimeStatsTracker[layerID];
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700397 if (layerRecord.timeRecords.size() == MAX_NUM_TIME_RECORDS) {
Yiwei Zhangaf8ee942018-11-22 00:15:23 -0800398 ALOGE("[%d]-[%s]-timeRecords is at its maximum size[%zu]. Ignore this when unittesting.",
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700399 layerID, layerRecord.layerName.c_str(), MAX_NUM_TIME_RECORDS);
Yiwei Zhangaf8ee942018-11-22 00:15:23 -0800400 mTimeStatsTracker.erase(layerID);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700401 return;
402 }
403 // For most media content, the acquireFence is invalid because the buffer is
404 // ready at the queueBuffer stage. In this case, acquireTime should be given
405 // a default value as postTime.
406 TimeRecord timeRecord = {
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700407 .frameTime =
408 {
409 .frameNumber = frameNumber,
410 .postTime = postTime,
Yiwei Zhangaf8ee942018-11-22 00:15:23 -0800411 .latchTime = postTime,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700412 .acquireTime = postTime,
Yiwei Zhangaf8ee942018-11-22 00:15:23 -0800413 .desiredTime = postTime,
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700414 },
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700415 };
416 layerRecord.timeRecords.push_back(timeRecord);
417 if (layerRecord.waitData < 0 ||
418 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
419 layerRecord.waitData = layerRecord.timeRecords.size() - 1;
420}
421
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700422void TimeStats::setLatchTime(int32_t layerID, uint64_t frameNumber, nsecs_t latchTime) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700423 if (!mEnabled.load()) return;
424
425 ATRACE_CALL();
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700426 ALOGV("[%d]-[%" PRIu64 "]-LatchTime[%" PRId64 "]", layerID, frameNumber, latchTime);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700427
428 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700429 if (!mTimeStatsTracker.count(layerID)) return;
430 LayerRecord& layerRecord = mTimeStatsTracker[layerID];
Yiwei Zhangcb7dd002019-04-16 11:03:01 -0700431 if (layerRecord.waitData < 0 ||
432 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
433 return;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700434 TimeRecord& timeRecord = layerRecord.timeRecords[layerRecord.waitData];
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700435 if (timeRecord.frameTime.frameNumber == frameNumber) {
436 timeRecord.frameTime.latchTime = latchTime;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700437 }
438}
439
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700440void TimeStats::setDesiredTime(int32_t layerID, uint64_t frameNumber, nsecs_t desiredTime) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700441 if (!mEnabled.load()) return;
442
443 ATRACE_CALL();
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700444 ALOGV("[%d]-[%" PRIu64 "]-DesiredTime[%" PRId64 "]", layerID, frameNumber, desiredTime);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700445
446 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700447 if (!mTimeStatsTracker.count(layerID)) return;
448 LayerRecord& layerRecord = mTimeStatsTracker[layerID];
Yiwei Zhangcb7dd002019-04-16 11:03:01 -0700449 if (layerRecord.waitData < 0 ||
450 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
451 return;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700452 TimeRecord& timeRecord = layerRecord.timeRecords[layerRecord.waitData];
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700453 if (timeRecord.frameTime.frameNumber == frameNumber) {
454 timeRecord.frameTime.desiredTime = desiredTime;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700455 }
456}
457
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700458void TimeStats::setAcquireTime(int32_t layerID, uint64_t frameNumber, nsecs_t acquireTime) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700459 if (!mEnabled.load()) return;
460
461 ATRACE_CALL();
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700462 ALOGV("[%d]-[%" PRIu64 "]-AcquireTime[%" PRId64 "]", layerID, frameNumber, acquireTime);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700463
464 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700465 if (!mTimeStatsTracker.count(layerID)) return;
466 LayerRecord& layerRecord = mTimeStatsTracker[layerID];
Yiwei Zhangcb7dd002019-04-16 11:03:01 -0700467 if (layerRecord.waitData < 0 ||
468 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
469 return;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700470 TimeRecord& timeRecord = layerRecord.timeRecords[layerRecord.waitData];
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700471 if (timeRecord.frameTime.frameNumber == frameNumber) {
472 timeRecord.frameTime.acquireTime = acquireTime;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700473 }
474}
475
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700476void TimeStats::setAcquireFence(int32_t layerID, uint64_t frameNumber,
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700477 const std::shared_ptr<FenceTime>& acquireFence) {
478 if (!mEnabled.load()) return;
479
480 ATRACE_CALL();
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700481 ALOGV("[%d]-[%" PRIu64 "]-AcquireFenceTime[%" PRId64 "]", layerID, frameNumber,
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700482 acquireFence->getSignalTime());
483
484 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700485 if (!mTimeStatsTracker.count(layerID)) return;
486 LayerRecord& layerRecord = mTimeStatsTracker[layerID];
Yiwei Zhangcb7dd002019-04-16 11:03:01 -0700487 if (layerRecord.waitData < 0 ||
488 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
489 return;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700490 TimeRecord& timeRecord = layerRecord.timeRecords[layerRecord.waitData];
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700491 if (timeRecord.frameTime.frameNumber == frameNumber) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700492 timeRecord.acquireFence = acquireFence;
493 }
494}
495
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700496void TimeStats::setPresentTime(int32_t layerID, uint64_t frameNumber, nsecs_t presentTime) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700497 if (!mEnabled.load()) return;
498
499 ATRACE_CALL();
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700500 ALOGV("[%d]-[%" PRIu64 "]-PresentTime[%" PRId64 "]", layerID, frameNumber, presentTime);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700501
502 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700503 if (!mTimeStatsTracker.count(layerID)) return;
504 LayerRecord& layerRecord = mTimeStatsTracker[layerID];
Yiwei Zhangcb7dd002019-04-16 11:03:01 -0700505 if (layerRecord.waitData < 0 ||
506 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
507 return;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700508 TimeRecord& timeRecord = layerRecord.timeRecords[layerRecord.waitData];
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700509 if (timeRecord.frameTime.frameNumber == frameNumber) {
510 timeRecord.frameTime.presentTime = presentTime;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700511 timeRecord.ready = true;
512 layerRecord.waitData++;
513 }
514
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700515 flushAvailableRecordsToStatsLocked(layerID);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700516}
517
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700518void TimeStats::setPresentFence(int32_t layerID, uint64_t frameNumber,
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700519 const std::shared_ptr<FenceTime>& presentFence) {
520 if (!mEnabled.load()) return;
521
522 ATRACE_CALL();
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700523 ALOGV("[%d]-[%" PRIu64 "]-PresentFenceTime[%" PRId64 "]", layerID, frameNumber,
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700524 presentFence->getSignalTime());
525
526 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700527 if (!mTimeStatsTracker.count(layerID)) return;
528 LayerRecord& layerRecord = mTimeStatsTracker[layerID];
Yiwei Zhangcb7dd002019-04-16 11:03:01 -0700529 if (layerRecord.waitData < 0 ||
530 layerRecord.waitData >= static_cast<int32_t>(layerRecord.timeRecords.size()))
531 return;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700532 TimeRecord& timeRecord = layerRecord.timeRecords[layerRecord.waitData];
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700533 if (timeRecord.frameTime.frameNumber == frameNumber) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700534 timeRecord.presentFence = presentFence;
535 timeRecord.ready = true;
536 layerRecord.waitData++;
537 }
538
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700539 flushAvailableRecordsToStatsLocked(layerID);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700540}
541
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700542void TimeStats::onDestroy(int32_t layerID) {
Yiwei Zhangdc224042018-10-18 15:34:00 -0700543 ATRACE_CALL();
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700544 ALOGV("[%d]-onDestroy", layerID);
Mikael Pessa2e1608f2019-07-19 11:25:35 -0700545 {
546 std::lock_guard<std::mutex> lock(mMutex);
547 mTimeStatsTracker.erase(layerID);
548 }
Yiwei Zhangdc224042018-10-18 15:34:00 -0700549
Mikael Pessa2e1608f2019-07-19 11:25:35 -0700550 {
551 std::lock_guard<std::mutex> traceLock(mTraceMutex);
552 mTraceTracker.erase(layerID);
553 }
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700554}
555
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700556void TimeStats::removeTimeRecord(int32_t layerID, uint64_t frameNumber) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700557 if (!mEnabled.load()) return;
558
559 ATRACE_CALL();
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700560 ALOGV("[%d]-[%" PRIu64 "]-removeTimeRecord", layerID, frameNumber);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700561
562 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700563 if (!mTimeStatsTracker.count(layerID)) return;
564 LayerRecord& layerRecord = mTimeStatsTracker[layerID];
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700565 size_t removeAt = 0;
566 for (const TimeRecord& record : layerRecord.timeRecords) {
Yiwei Zhangcf50ab92018-06-14 10:50:12 -0700567 if (record.frameTime.frameNumber == frameNumber) break;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700568 removeAt++;
569 }
570 if (removeAt == layerRecord.timeRecords.size()) return;
571 layerRecord.timeRecords.erase(layerRecord.timeRecords.begin() + removeAt);
572 if (layerRecord.waitData > static_cast<int32_t>(removeAt)) {
Yiwei Zhangeaeea062018-06-28 14:46:51 -0700573 layerRecord.waitData--;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700574 }
Yiwei Zhangeaeea062018-06-28 14:46:51 -0700575 layerRecord.droppedFrames++;
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700576}
577
Yiwei Zhang3a226d22018-10-16 09:23:03 -0700578void TimeStats::flushPowerTimeLocked() {
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700579 if (!mEnabled.load()) return;
580
Yiwei Zhang3a226d22018-10-16 09:23:03 -0700581 nsecs_t curTime = systemTime();
582 // elapsedTime is in milliseconds.
583 int64_t elapsedTime = (curTime - mPowerTime.prevTime) / 1000000;
584
585 switch (mPowerTime.powerMode) {
586 case HWC_POWER_MODE_NORMAL:
587 mTimeStats.displayOnTime += elapsedTime;
588 break;
589 case HWC_POWER_MODE_OFF:
590 case HWC_POWER_MODE_DOZE:
591 case HWC_POWER_MODE_DOZE_SUSPEND:
592 default:
593 break;
594 }
595
596 mPowerTime.prevTime = curTime;
597}
598
599void TimeStats::setPowerMode(int32_t powerMode) {
600 if (!mEnabled.load()) {
601 std::lock_guard<std::mutex> lock(mMutex);
602 mPowerTime.powerMode = powerMode;
603 return;
604 }
605
606 std::lock_guard<std::mutex> lock(mMutex);
607 if (powerMode == mPowerTime.powerMode) return;
608
609 flushPowerTimeLocked();
610 mPowerTime.powerMode = powerMode;
611}
612
Alec Mourifb571ea2019-01-24 18:42:10 -0800613void TimeStats::recordRefreshRate(uint32_t fps, nsecs_t duration) {
614 std::lock_guard<std::mutex> lock(mMutex);
615 if (mTimeStats.refreshRateStats.count(fps)) {
616 mTimeStats.refreshRateStats[fps] += duration;
617 } else {
618 mTimeStats.refreshRateStats.insert({fps, duration});
619 }
620}
621
Yiwei Zhangce6ebc02018-10-20 12:42:38 -0700622void TimeStats::flushAvailableGlobalRecordsToStatsLocked() {
623 ATRACE_CALL();
624
625 while (!mGlobalRecord.presentFences.empty()) {
626 const nsecs_t curPresentTime = mGlobalRecord.presentFences.front()->getSignalTime();
627 if (curPresentTime == Fence::SIGNAL_TIME_PENDING) break;
628
629 if (curPresentTime == Fence::SIGNAL_TIME_INVALID) {
630 ALOGE("GlobalPresentFence is invalid!");
631 mGlobalRecord.prevPresentTime = 0;
632 mGlobalRecord.presentFences.pop_front();
633 continue;
634 }
635
636 ALOGV("GlobalPresentFenceTime[%" PRId64 "]",
637 mGlobalRecord.presentFences.front()->getSignalTime());
638
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700639 if (mGlobalRecord.prevPresentTime != 0) {
640 const int32_t presentToPresentMs =
641 msBetween(mGlobalRecord.prevPresentTime, curPresentTime);
642 ALOGV("Global present2present[%d] prev[%" PRId64 "] curr[%" PRId64 "]",
643 presentToPresentMs, mGlobalRecord.prevPresentTime, curPresentTime);
644 mTimeStats.presentToPresent.insert(presentToPresentMs);
645 }
Yiwei Zhangce6ebc02018-10-20 12:42:38 -0700646
Yiwei Zhangce6ebc02018-10-20 12:42:38 -0700647 mGlobalRecord.prevPresentTime = curPresentTime;
648 mGlobalRecord.presentFences.pop_front();
649 }
650}
651
652void TimeStats::setPresentFenceGlobal(const std::shared_ptr<FenceTime>& presentFence) {
653 if (!mEnabled.load()) return;
654
655 ATRACE_CALL();
656 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700657 if (presentFence == nullptr || !presentFence->isValid()) {
658 mGlobalRecord.prevPresentTime = 0;
659 return;
660 }
661
662 if (mPowerTime.powerMode != HWC_POWER_MODE_NORMAL) {
663 // Try flushing the last present fence on HWC_POWER_MODE_NORMAL.
664 flushAvailableGlobalRecordsToStatsLocked();
665 mGlobalRecord.presentFences.clear();
Yiwei Zhangce6ebc02018-10-20 12:42:38 -0700666 mGlobalRecord.prevPresentTime = 0;
667 return;
668 }
669
670 if (mGlobalRecord.presentFences.size() == MAX_NUM_TIME_RECORDS) {
671 // The front presentFence must be trapped in pending status in this
672 // case. Try dequeuing the front one to recover.
673 ALOGE("GlobalPresentFences is already at its maximum size[%zu]", MAX_NUM_TIME_RECORDS);
674 mGlobalRecord.prevPresentTime = 0;
675 mGlobalRecord.presentFences.pop_front();
676 }
677
678 mGlobalRecord.presentFences.emplace_back(presentFence);
679 flushAvailableGlobalRecordsToStatsLocked();
680}
681
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700682void TimeStats::enable() {
683 if (mEnabled.load()) return;
684
685 ATRACE_CALL();
686
687 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700688 mEnabled.store(true);
Yiwei Zhangdc224042018-10-18 15:34:00 -0700689 mTimeStats.statsStart = static_cast<int64_t>(std::time(0));
Yiwei Zhang3a226d22018-10-16 09:23:03 -0700690 mPowerTime.prevTime = systemTime();
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700691 ALOGD("Enabled");
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700692}
693
694void TimeStats::disable() {
695 if (!mEnabled.load()) return;
696
697 ATRACE_CALL();
698
699 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700700 flushPowerTimeLocked();
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700701 mEnabled.store(false);
Yiwei Zhangdc224042018-10-18 15:34:00 -0700702 mTimeStats.statsEnd = static_cast<int64_t>(std::time(0));
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700703 ALOGD("Disabled");
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700704}
705
706void TimeStats::clear() {
707 ATRACE_CALL();
708
709 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700710 mTimeStatsTracker.clear();
Yiwei Zhangdc224042018-10-18 15:34:00 -0700711 mTimeStats.stats.clear();
712 mTimeStats.statsStart = (mEnabled.load() ? static_cast<int64_t>(std::time(0)) : 0);
713 mTimeStats.statsEnd = 0;
714 mTimeStats.totalFrames = 0;
715 mTimeStats.missedFrames = 0;
716 mTimeStats.clientCompositionFrames = 0;
Yiwei Zhang3a226d22018-10-16 09:23:03 -0700717 mTimeStats.displayOnTime = 0;
Yiwei Zhangce6ebc02018-10-20 12:42:38 -0700718 mTimeStats.presentToPresent.hist.clear();
Alec Mourifb571ea2019-01-24 18:42:10 -0800719 mTimeStats.refreshRateStats.clear();
Yiwei Zhang3a226d22018-10-16 09:23:03 -0700720 mPowerTime.prevTime = systemTime();
Yiwei Zhange5c49d52018-10-29 00:15:31 -0700721 mGlobalRecord.prevPresentTime = 0;
722 mGlobalRecord.presentFences.clear();
723 ALOGD("Cleared");
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700724}
725
726bool TimeStats::isEnabled() {
727 return mEnabled.load();
728}
729
Yiwei Zhang5434a782018-12-05 18:06:32 -0800730void TimeStats::dump(bool asProto, std::optional<uint32_t> maxLayers, std::string& result) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700731 ATRACE_CALL();
732
733 std::lock_guard<std::mutex> lock(mMutex);
Yiwei Zhangdc224042018-10-18 15:34:00 -0700734 if (mTimeStats.statsStart == 0) {
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700735 return;
736 }
737
Yiwei Zhangdc224042018-10-18 15:34:00 -0700738 mTimeStats.statsEnd = static_cast<int64_t>(std::time(0));
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700739
Yiwei Zhang3a226d22018-10-16 09:23:03 -0700740 flushPowerTimeLocked();
741
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700742 if (asProto) {
Yiwei Zhang8a4015c2018-05-08 16:03:47 -0700743 ALOGD("Dumping TimeStats as proto");
Yiwei Zhangdc224042018-10-18 15:34:00 -0700744 SFTimeStatsGlobalProto timeStatsProto = mTimeStats.toProto(maxLayers);
Dominik Laskowski46470112019-08-02 13:13:11 -0700745 result.append(timeStatsProto.SerializeAsString());
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700746 } else {
Yiwei Zhang8a4015c2018-05-08 16:03:47 -0700747 ALOGD("Dumping TimeStats as text");
Yiwei Zhang5434a782018-12-05 18:06:32 -0800748 result.append(mTimeStats.toString(maxLayers));
Yiwei Zhang8a4015c2018-05-08 16:03:47 -0700749 result.append("\n");
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700750 }
751}
752
Alec Mourifb571ea2019-01-24 18:42:10 -0800753} // namespace impl
754
Yiwei Zhang0102ad22018-05-02 17:37:17 -0700755} // namespace android