summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAllen Hair <allenhair@google.com>2015-03-06 16:58:26 -0800
committerAllen Hair <allenhair@google.com>2015-03-07 01:24:10 +0000
commit0777807782445cf073cc83ffc242777ca6ab3328 (patch)
tree7a532d273a324e62952afe6e098f6a00015fc597 /src
parentaefcdcd1240f666bc0c85a9a1de8848f5665080e (diff)
downloadjanktesthelper-0777807782445cf073cc83ffc242777ca6ab3328.tar.gz
Make monitor key values public.
Change-Id: I739b5fca287650548e4319ecd8c52fb1d3cc1337
Diffstat (limited to 'src')
-rw-r--r--src/android/support/test/jank/GfxMonitor.java13
-rw-r--r--src/android/support/test/jank/WindowAnimationFrameStatsMonitor.java4
-rw-r--r--src/android/support/test/jank/WindowContentFrameStatsMonitor.java4
-rw-r--r--src/android/support/test/jank/internal/FrameStatsMonitorBase.java26
-rw-r--r--src/android/support/test/jank/internal/GfxMonitorImpl.java50
-rw-r--r--src/android/support/test/jank/internal/MetricsHelper.java33
-rw-r--r--src/android/support/test/jank/internal/WindowAnimationFrameMonitorImpl.java24
-rw-r--r--src/android/support/test/jank/internal/WindowContentFrameMonitorImpl.java24
8 files changed, 105 insertions, 73 deletions
diff --git a/src/android/support/test/jank/GfxMonitor.java b/src/android/support/test/jank/GfxMonitor.java
index 36ca81b..f60c5d1 100644
--- a/src/android/support/test/jank/GfxMonitor.java
+++ b/src/android/support/test/jank/GfxMonitor.java
@@ -27,4 +27,17 @@ import java.lang.annotation.Target;
public @interface GfxMonitor {
/** The name of the process to monitor */
String processName();
+
+ public static final String KEY_AVG_NUM_JANKY = "gfx-avg-jank";
+ public static final String KEY_MAX_NUM_JANKY = "gfx-max-jank";
+ public static final String KEY_AVG_MISSED_VSYNC = "gfx-avg-missed-vsync";
+ public static final String KEY_MAX_MISSED_VSYNC = "gfx-max-missed-vsync";
+ public static final String KEY_AVG_HIGH_INPUT_LATENCY = "gfx-avg-high-input-latency";
+ public static final String KEY_MAX_HIGH_INPUT_LATENCY = "gfx-max-high-input-latency";
+ public static final String KEY_AVG_SLOW_UI_THREAD = "gfx-avg-slow-ui-thread";
+ public static final String KEY_MAX_SLOW_UI_THREAD = "gfx-max-slow-ui-thread";
+ public static final String KEY_AVG_SLOW_BITMAP_UPLOADS = "gfx-avg-slow-bitmap-uploads";
+ public static final String KEY_MAX_SLOW_BITMAP_UPLOADS = "gfx-max-slow-bitmap-uploads";
+ public static final String KEY_AVG_SLOW_DRAW = "gfx-avg-slow-draw";
+ public static final String KEY_MAX_SLOW_DRAW = "gfx-max-slow-draw";
}
diff --git a/src/android/support/test/jank/WindowAnimationFrameStatsMonitor.java b/src/android/support/test/jank/WindowAnimationFrameStatsMonitor.java
index 1f7ab57..79b466b 100644
--- a/src/android/support/test/jank/WindowAnimationFrameStatsMonitor.java
+++ b/src/android/support/test/jank/WindowAnimationFrameStatsMonitor.java
@@ -25,4 +25,8 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface WindowAnimationFrameStatsMonitor {
+ public static final String KEY_AVG_NUM_JANKY = "frame-avg-jank";
+ public static final String KEY_MAX_NUM_JANKY = "frame-max-jank";
+ public static final String KEY_AVG_FPS = "frame-fps";
+ public static final String KEY_AVG_LONGEST_FRAME = "frame-max-frame-duration";
}
diff --git a/src/android/support/test/jank/WindowContentFrameStatsMonitor.java b/src/android/support/test/jank/WindowContentFrameStatsMonitor.java
index 034eec7..848aeca 100644
--- a/src/android/support/test/jank/WindowContentFrameStatsMonitor.java
+++ b/src/android/support/test/jank/WindowContentFrameStatsMonitor.java
@@ -25,4 +25,8 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface WindowContentFrameStatsMonitor {
+ public static final String KEY_AVG_NUM_JANKY = "frame-avg-jank";
+ public static final String KEY_MAX_NUM_JANKY = "frame-max-jank";
+ public static final String KEY_AVG_FPS = "frame-fps";
+ public static final String KEY_AVG_LONGEST_FRAME = "frame-max-frame-duration";
}
diff --git a/src/android/support/test/jank/internal/FrameStatsMonitorBase.java b/src/android/support/test/jank/internal/FrameStatsMonitorBase.java
index 162af3a..8821b14 100644
--- a/src/android/support/test/jank/internal/FrameStatsMonitorBase.java
+++ b/src/android/support/test/jank/internal/FrameStatsMonitorBase.java
@@ -16,7 +16,6 @@
package android.support.test.jank.internal;
-import android.os.Bundle;
import android.util.Log;
import android.view.FrameStats;
@@ -38,36 +37,11 @@ abstract class FrameStatsMonitorBase implements JankMonitor {
// Maximum normalized frame duration before the frame is considered a pause
private static final double PAUSE_THRESHOLD = 15.0f;
- // Jank metrics namespace and helper class
- private static final String MONITOR_PREFIX = "frame";
- private static final MetricsHelper mMetricsHelper = new MetricsHelper(MONITOR_PREFIX);
-
- // Key values for the metrics reported by this monitor
- private static final String KEY_NUM_JANKY = "jank";
- private static final String KEY_FPS = "fps";
- private static final String KEY_LONGEST_FRAME = "max-frame-duration";
-
// Accumulated stats
ArrayList<Integer> mJankyFrames = new ArrayList<Integer>();
ArrayList<Double> mFps = new ArrayList<Double>();
ArrayList<Double> mLongestNormalizedFrames = new ArrayList<Double>();
-
- public Bundle getMetrics() {
- Bundle metrics = new Bundle();
-
- // Store average and max jank
- mMetricsHelper.putSummaryMetrics(metrics, KEY_NUM_JANKY, mJankyFrames);
-
- // Store average fps
- mMetricsHelper.putAverageMetric(metrics, KEY_FPS, mFps);
-
- // Store average max frame duration
- mMetricsHelper.putAverageMetric(metrics, KEY_LONGEST_FRAME, mLongestNormalizedFrames);
-
- return metrics;
- }
-
protected void analyze(FrameStats stats) {
int frameCount = stats.getFrameCount();
long refreshPeriod = stats.getRefreshPeriodNano();
diff --git a/src/android/support/test/jank/internal/GfxMonitorImpl.java b/src/android/support/test/jank/internal/GfxMonitorImpl.java
index 9aae574..0878847 100644
--- a/src/android/support/test/jank/internal/GfxMonitorImpl.java
+++ b/src/android/support/test/jank/internal/GfxMonitorImpl.java
@@ -19,12 +19,13 @@ package android.support.test.jank.internal;
import android.app.UiAutomation;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
+import android.support.test.jank.GfxMonitor;
import java.io.BufferedReader;
-import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
@@ -39,18 +40,6 @@ import junit.framework.Assert;
*/
class GfxMonitorImpl implements JankMonitor {
- // Jank metrics namespace and helper class
- private static final String MONITOR_PREFIX = "gfx";
- private static final MetricsHelper mMetricsHelper = new MetricsHelper(MONITOR_PREFIX);
-
- // Key values for the metrics reported by this monitor
- private static final String KEY_NUM_JANKY = "jank";
- private static final String KEY_MISSED_VSYNC = "missed-vsync";
- private static final String KEY_HIGH_INPUT_LATENCY = "high-input-latency";
- private static final String KEY_SLOW_UI_THREAD = "slow-ui-thread";
- private static final String KEY_SLOW_BITMAP_UPLOADS = "slow-bitmap-uploads";
- private static final String KEY_SLOW_DRAW = "slow-draw";
-
// Patterns used for parsing dumpsys gfxinfo output
private static final Pattern TOTAL_FRAMES_PATTERN =
Pattern.compile("\\s*Total frames rendered: (\\d+)");
@@ -173,12 +162,35 @@ class GfxMonitorImpl implements JankMonitor {
public Bundle getMetrics() {
Bundle metrics = new Bundle();
- mMetricsHelper.putSummaryMetrics(metrics, KEY_NUM_JANKY, jankyFrames);
- mMetricsHelper.putSummaryMetrics(metrics, KEY_MISSED_VSYNC, missedVsync);
- mMetricsHelper.putSummaryMetrics(metrics, KEY_HIGH_INPUT_LATENCY, highInputLatency);
- mMetricsHelper.putSummaryMetrics(metrics, KEY_SLOW_UI_THREAD, slowUiThread);
- mMetricsHelper.putSummaryMetrics(metrics, KEY_SLOW_BITMAP_UPLOADS, slowBitmapUploads);
- mMetricsHelper.putSummaryMetrics(metrics, KEY_SLOW_DRAW, slowDraw);
+
+ // Store average and max jank
+ metrics.putDouble(GfxMonitor.KEY_AVG_NUM_JANKY,
+ MetricsHelper.computeAverageInt(jankyFrames));
+ metrics.putInt(GfxMonitor.KEY_MAX_NUM_JANKY, Collections.max(jankyFrames));
+
+ // Store average and max missed vsync
+ metrics.putDouble(GfxMonitor.KEY_AVG_MISSED_VSYNC,
+ MetricsHelper.computeAverageInt(missedVsync));
+ metrics.putInt(GfxMonitor.KEY_MAX_MISSED_VSYNC, Collections.max(missedVsync));
+
+ // Store average and max high input latency
+ metrics.putDouble(GfxMonitor.KEY_AVG_HIGH_INPUT_LATENCY,
+ MetricsHelper.computeAverageInt(highInputLatency));
+ metrics.putInt(GfxMonitor.KEY_MAX_HIGH_INPUT_LATENCY, Collections.max(highInputLatency));
+
+ // Store average and max slow ui thread
+ metrics.putDouble(GfxMonitor.KEY_AVG_SLOW_UI_THREAD,
+ MetricsHelper.computeAverageInt(slowUiThread));
+ metrics.putInt(GfxMonitor.KEY_MAX_SLOW_UI_THREAD, Collections.max(slowUiThread));
+
+ // Store average and max slow bitmap uploads
+ metrics.putDouble(GfxMonitor.KEY_AVG_SLOW_BITMAP_UPLOADS,
+ MetricsHelper.computeAverageInt(slowUiThread));
+ metrics.putInt(GfxMonitor.KEY_MAX_SLOW_BITMAP_UPLOADS, Collections.max(slowUiThread));
+
+ // Store average and max slow draw
+ metrics.putDouble(GfxMonitor.KEY_AVG_SLOW_DRAW, MetricsHelper.computeAverageInt(slowDraw));
+ metrics.putInt(GfxMonitor.KEY_MAX_SLOW_DRAW, Collections.max(slowDraw));
return metrics;
}
diff --git a/src/android/support/test/jank/internal/MetricsHelper.java b/src/android/support/test/jank/internal/MetricsHelper.java
index 8a88c88..20ba8d2 100644
--- a/src/android/support/test/jank/internal/MetricsHelper.java
+++ b/src/android/support/test/jank/internal/MetricsHelper.java
@@ -16,46 +16,23 @@
package android.support.test.jank.internal;
-import android.os.Bundle;
-import android.text.TextUtils;
-
import java.util.List;
class MetricsHelper {
- private static final String KEY_SEPARATOR = "-";
- private static final String MAX_VALUE_PREFIX = "max";
- private static final String AVG_VALUE_PREFIX = "avg";
-
- private final String mMonitorPrefix;
-
- public MetricsHelper(String monitorPrefix) {
- mMonitorPrefix = monitorPrefix;
- }
-
- /** Stores the average metric for the given set of values. */
- public void putAverageMetric(Bundle metrics, String key, List<Double> values) {
+ public static double computeAverageFloat(List<Double> values) {
double sum = 0.0f;
for (Double value : values) {
sum += value;
}
- metrics.putDouble(joinKey(mMonitorPrefix, MAX_VALUE_PREFIX, key), sum / values.size());
+ return sum / values.size();
}
- /** Stores the average and max metrics for the given set of values. */
- public void putSummaryMetrics(Bundle metrics, String key, List<Integer> values) {
- int max = -1;
- int sum = 0;
+ public static double computeAverageInt(List<Integer> values) {
+ double sum = 0.0f;
for (Integer value : values) {
- max = Math.max(max, value);
sum += value;
}
- metrics.putInt(joinKey(mMonitorPrefix, MAX_VALUE_PREFIX, key), max);
- metrics.putDouble(joinKey(mMonitorPrefix, AVG_VALUE_PREFIX, key),
- (double)sum / values.size());
- }
-
- private String joinKey(String... parts) {
- return TextUtils.join(KEY_SEPARATOR, parts);
+ return sum / values.size();
}
}
diff --git a/src/android/support/test/jank/internal/WindowAnimationFrameMonitorImpl.java b/src/android/support/test/jank/internal/WindowAnimationFrameMonitorImpl.java
index 1fed858..2a0ad11 100644
--- a/src/android/support/test/jank/internal/WindowAnimationFrameMonitorImpl.java
+++ b/src/android/support/test/jank/internal/WindowAnimationFrameMonitorImpl.java
@@ -17,8 +17,12 @@
package android.support.test.jank.internal;
import android.app.UiAutomation;
+import android.os.Bundle;
+import android.support.test.jank.WindowAnimationFrameStatsMonitor;
import android.view.FrameStats;
+import java.util.Collections;
+
/**
* Monitors {@link android.view.WindowAnimationFrameStats} to detect janky frames.
*
@@ -32,6 +36,26 @@ class WindowAnimationFrameStatsMonitorImpl extends FrameStatsMonitorBase {
mUiAutomation = automation;
}
+ public Bundle getMetrics() {
+ Bundle metrics = new Bundle();
+
+ // Store average and max jank
+ metrics.putDouble(WindowAnimationFrameStatsMonitor.KEY_AVG_NUM_JANKY,
+ MetricsHelper.computeAverageInt(mJankyFrames));
+ metrics.putInt(WindowAnimationFrameStatsMonitor.KEY_MAX_NUM_JANKY,
+ Collections.max(mJankyFrames));
+
+ // Store average fps
+ metrics.putDouble(WindowAnimationFrameStatsMonitor.KEY_AVG_FPS,
+ MetricsHelper.computeAverageFloat(mFps));
+
+ // Store average max frame duration
+ metrics.putDouble(WindowAnimationFrameStatsMonitor.KEY_AVG_LONGEST_FRAME,
+ MetricsHelper.computeAverageFloat(mLongestNormalizedFrames));
+
+ return metrics;
+ }
+
@Override
public void startIteration() {
// Clear out any previous data
diff --git a/src/android/support/test/jank/internal/WindowContentFrameMonitorImpl.java b/src/android/support/test/jank/internal/WindowContentFrameMonitorImpl.java
index 9ff3a94..30db841 100644
--- a/src/android/support/test/jank/internal/WindowContentFrameMonitorImpl.java
+++ b/src/android/support/test/jank/internal/WindowContentFrameMonitorImpl.java
@@ -18,11 +18,15 @@ package android.support.test.jank.internal;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.UiAutomation;
+import android.os.Bundle;
+import android.support.test.jank.WindowContentFrameStatsMonitor;
import android.util.Log;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityWindowInfo;
import android.view.FrameStats;
+import java.util.Collections;
+
/**
* Monitors {@link android.view.WindowContentFrameStats} to detect janky frames.
*
@@ -39,6 +43,26 @@ class WindowContentFrameStatsMonitorImpl extends FrameStatsMonitorBase {
mUiAutomation = automation;
}
+ public Bundle getMetrics() {
+ Bundle metrics = new Bundle();
+
+ // Store average and max jank
+ metrics.putDouble(WindowContentFrameStatsMonitor.KEY_AVG_NUM_JANKY,
+ MetricsHelper.computeAverageInt(mJankyFrames));
+ metrics.putInt(WindowContentFrameStatsMonitor.KEY_MAX_NUM_JANKY,
+ Collections.max(mJankyFrames));
+
+ // Store average fps
+ metrics.putDouble(WindowContentFrameStatsMonitor.KEY_AVG_FPS,
+ MetricsHelper.computeAverageFloat(mFps));
+
+ // Store average max frame duration
+ metrics.putDouble(WindowContentFrameStatsMonitor.KEY_AVG_LONGEST_FRAME,
+ MetricsHelper.computeAverageFloat(mLongestNormalizedFrames));
+
+ return metrics;
+ }
+
@Override
public void startIteration() {
// Save the window id