diff options
author | John Reck <jreck@google.com> | 2015-03-06 14:40:50 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2015-03-06 15:40:03 -0800 |
commit | e70c5754d01f2ab0ff47ea3eabaa88aca5ed2a36 (patch) | |
tree | 6bb1f487801fe47250443fdb65a9f82d66264c72 /libs | |
parent | 38d909a57d95d29e6c47f40d360bc10325d7b228 (diff) | |
download | frameworks_base-e70c5754d01f2ab0ff47ea3eabaa88aca5ed2a36.zip frameworks_base-e70c5754d01f2ab0ff47ea3eabaa88aca5ed2a36.tar.gz frameworks_base-e70c5754d01f2ab0ff47ea3eabaa88aca5ed2a36.tar.bz2 |
Add percentiles
Change-Id: Ieb6badd177bb6f67dda199dfcb3e0f483c8c4e59
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/JankTracker.cpp | 25 | ||||
-rw-r--r-- | libs/hwui/JankTracker.h | 3 |
2 files changed, 27 insertions, 1 deletions
diff --git a/libs/hwui/JankTracker.cpp b/libs/hwui/JankTracker.cpp index d0ea3a6..46b0945 100644 --- a/libs/hwui/JankTracker.cpp +++ b/libs/hwui/JankTracker.cpp @@ -15,6 +15,7 @@ */ #include "JankTracker.h" +#include <algorithm> #include <cstdio> #include <inttypes.h> @@ -95,7 +96,12 @@ void JankTracker::addFrame(const FrameInfo& frame) { // Fast-path for jank-free frames int64_t totalDuration = frame[FrameInfoIndex::kFrameCompleted] - frame[FrameInfoIndex::kIntendedVsync]; + uint32_t framebucket = std::min( + static_cast<typeof sizeof(mFrameCounts)>(ns2ms(totalDuration)), + sizeof(mFrameCounts) / sizeof(mFrameCounts[0])); + // Keep the fast path as fast as possible. if (CC_LIKELY(totalDuration < mFrameInterval)) { + mFrameCounts[framebucket]++; return; } @@ -103,6 +109,7 @@ void JankTracker::addFrame(const FrameInfo& frame) { return; } + mFrameCounts[framebucket]++; mJankFrameCount++; for (int i = 0; i < NUM_BUCKETS; i++) { @@ -119,6 +126,9 @@ void JankTracker::dump(int fd) { fprintf(file, "\n Total frames rendered: %u", mTotalFrameCount); fprintf(file, "\n Janky frames: %u (%.2f%%)", mJankFrameCount, (float) mJankFrameCount / (float) mTotalFrameCount * 100.0f); + fprintf(file, "\n 90th percentile: %ums", findPercentile(90)); + fprintf(file, "\n 95th percentile: %ums", findPercentile(95)); + fprintf(file, "\n 99th percentile: %ums", findPercentile(99)); for (int i = 0; i < NUM_BUCKETS; i++) { fprintf(file, "\n Number %s: %u", JANK_TYPE_NAMES[i], mBuckets[i].count); } @@ -127,10 +137,23 @@ void JankTracker::dump(int fd) { } void JankTracker::reset() { - memset(mBuckets, 0, sizeof(JankBucket) * NUM_BUCKETS); + memset(mBuckets, 0, sizeof(mBuckets)); + memset(mFrameCounts, 0, sizeof(mFrameCounts)); mTotalFrameCount = 0; mJankFrameCount = 0; } +uint32_t JankTracker::findPercentile(int percentile) { + int pos = percentile * mTotalFrameCount / 100; + int remaining = mTotalFrameCount - pos; + for (int i = sizeof(mFrameCounts) / sizeof(mFrameCounts[0]) - 1; i >= 0; i--) { + remaining -= mFrameCounts[i]; + if (remaining <= 0) { + return i; + } + } + return 0; +} + } /* namespace uirenderer */ } /* namespace android */ diff --git a/libs/hwui/JankTracker.h b/libs/hwui/JankTracker.h index aa554cd..3d4929b 100644 --- a/libs/hwui/JankTracker.h +++ b/libs/hwui/JankTracker.h @@ -54,8 +54,11 @@ public: void reset(); private: + uint32_t findPercentile(int p); + JankBucket mBuckets[NUM_BUCKETS]; int64_t mThresholds[NUM_BUCKETS]; + uint32_t mFrameCounts[128]; int64_t mFrameInterval; uint32_t mTotalFrameCount; |