summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllen Hair <allenhair@google.com>2015-05-21 15:54:46 -0700
committerAllen Hair <allenhair@google.com>2015-05-21 15:54:46 -0700
commitd6d9f3128d6ae8da7998c997d5d0ddebb1777935 (patch)
tree4d7a193cecc6b46c3e5a94dc64acf830a3d6ed3d
parenteb1d7fefb2b96d990315254ab3fcd97dc4adfdee (diff)
downloadjanktesthelper-d6d9f3128d6ae8da7998c997d5d0ddebb1777935.tar.gz
Change remaining count metrics to percentages.
Change-Id: Icf3ecb657a5f960973c7e867a33d7acc947af65a
-rw-r--r--src/main/java/android/support/test/jank/internal/GfxMonitorImpl.java52
1 files changed, 39 insertions, 13 deletions
diff --git a/src/main/java/android/support/test/jank/internal/GfxMonitorImpl.java b/src/main/java/android/support/test/jank/internal/GfxMonitorImpl.java
index c1f7b9b..0b3a87b 100644
--- a/src/main/java/android/support/test/jank/internal/GfxMonitorImpl.java
+++ b/src/main/java/android/support/test/jank/internal/GfxMonitorImpl.java
@@ -27,6 +27,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumMap;
+import java.util.Iterator;
import java.util.Map;
import java.util.List;
import java.util.regex.Pattern;
@@ -201,9 +202,27 @@ class GfxMonitorImpl implements JankMonitor {
metrics.putDouble(maxKey, Collections.max(values));
}
+ private List<Double> transformToPercentage(List<Integer> values, List<Integer> totals) {
+ List<Double> ret = new ArrayList<Double>(values.size());
+
+ Iterator<Integer> valuesItr = values.iterator();
+ Iterator<Integer> totalsItr = totals.iterator();
+ while (valuesItr.hasNext()) {
+ double value = (double)valuesItr.next().intValue();
+ double total = (double)totalsItr.next().intValue();
+
+ ret.add(value / total * 100.0f);
+ }
+
+ return ret;
+ }
+
public Bundle getMetrics() {
Bundle metrics = new Bundle();
+ // Retrieve the total number of frames
+ List<Integer> totals = (List<Integer>)mAccumulatedStats.get(JankStat.TOTAL_FRAMES);
+
// Store average and max jank
putAvgMaxDouble(metrics, GfxMonitor.KEY_AVG_NUM_JANKY, GfxMonitor.KEY_MAX_NUM_JANKY,
(List<Double>)mAccumulatedStats.get(JankStat.NUM_JANKY));
@@ -220,27 +239,34 @@ class GfxMonitorImpl implements JankMonitor {
(List<Integer>)mAccumulatedStats.get(JankStat.FRAME_TIME_99TH));
// Store average and max missed vsync
- putAvgMaxInteger(metrics, GfxMonitor.KEY_AVG_MISSED_VSYNC, GfxMonitor.KEY_MAX_MISSED_VSYNC,
- (List<Integer>)mAccumulatedStats.get(JankStat.NUM_MISSED_VSYNC));
+ List<Double> missedVsyncPercent = transformToPercentage(
+ (List<Integer>)mAccumulatedStats.get(JankStat.NUM_MISSED_VSYNC), totals);
+ putAvgMaxDouble(metrics, GfxMonitor.KEY_AVG_MISSED_VSYNC, GfxMonitor.KEY_MAX_MISSED_VSYNC,
+ missedVsyncPercent);
// Store average and max high input latency
- putAvgMaxInteger(metrics, GfxMonitor.KEY_AVG_HIGH_INPUT_LATENCY,
- GfxMonitor.KEY_MAX_HIGH_INPUT_LATENCY,
- (List<Integer>)mAccumulatedStats.get(JankStat.NUM_HIGH_INPUT_LATENCY));
+ List<Double> highInputLatencyPercent = transformToPercentage(
+ (List<Integer>)mAccumulatedStats.get(JankStat.NUM_HIGH_INPUT_LATENCY), totals);
+ putAvgMaxDouble(metrics, GfxMonitor.KEY_AVG_HIGH_INPUT_LATENCY,
+ GfxMonitor.KEY_MAX_HIGH_INPUT_LATENCY, highInputLatencyPercent);
// Store average and max slow ui thread
- putAvgMaxInteger(metrics, GfxMonitor.KEY_AVG_SLOW_UI_THREAD,
- GfxMonitor.KEY_MAX_SLOW_UI_THREAD,
- (List<Integer>)mAccumulatedStats.get(JankStat.NUM_SLOW_UI_THREAD));
+ List<Double> slowUiThreadPercent = transformToPercentage(
+ (List<Integer>)mAccumulatedStats.get(JankStat.NUM_SLOW_UI_THREAD), totals);
+ putAvgMaxDouble(metrics, GfxMonitor.KEY_AVG_SLOW_UI_THREAD,
+ GfxMonitor.KEY_MAX_SLOW_UI_THREAD, slowUiThreadPercent);
// Store average and max slow bitmap uploads
- putAvgMaxInteger(metrics, GfxMonitor.KEY_AVG_SLOW_BITMAP_UPLOADS,
- GfxMonitor.KEY_MAX_SLOW_BITMAP_UPLOADS,
- (List<Integer>)mAccumulatedStats.get(JankStat.NUM_SLOW_BITMAP_UPLOADS));
+ List<Double> slowBitMapUploadsPercent = transformToPercentage(
+ (List<Integer>)mAccumulatedStats.get(JankStat.NUM_SLOW_BITMAP_UPLOADS), totals);
+ putAvgMaxDouble(metrics, GfxMonitor.KEY_AVG_SLOW_BITMAP_UPLOADS,
+ GfxMonitor.KEY_MAX_SLOW_BITMAP_UPLOADS, slowBitMapUploadsPercent);
// Store average and max slow draw
- putAvgMaxInteger(metrics, GfxMonitor.KEY_AVG_SLOW_DRAW, GfxMonitor.KEY_MAX_SLOW_DRAW,
- (List<Integer>)mAccumulatedStats.get(JankStat.NUM_SLOW_DRAW));
+ List<Double> slowDrawPercent = transformToPercentage(
+ (List<Integer>)mAccumulatedStats.get(JankStat.NUM_SLOW_DRAW), totals);
+ putAvgMaxDouble(metrics, GfxMonitor.KEY_AVG_SLOW_DRAW, GfxMonitor.KEY_MAX_SLOW_DRAW,
+ slowDrawPercent);
return metrics;
}