summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2015-03-06 23:47:25 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-03-06 23:47:26 +0000
commitaa35d91905be64ae3468b95d4a177940f935e8e6 (patch)
tree21dcc7f30c18bdf981e0e4d8883878848e1d56ad /libs
parentc0a1b7f9a6a496deb68b095d122ca85f22daad98 (diff)
parente70c5754d01f2ab0ff47ea3eabaa88aca5ed2a36 (diff)
downloadframeworks_base-aa35d91905be64ae3468b95d4a177940f935e8e6.zip
frameworks_base-aa35d91905be64ae3468b95d4a177940f935e8e6.tar.gz
frameworks_base-aa35d91905be64ae3468b95d4a177940f935e8e6.tar.bz2
Merge "Add percentiles"
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/JankTracker.cpp25
-rw-r--r--libs/hwui/JankTracker.h3
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;