Bug 938827 - Part 2: Call PanningPerfAPI directly. r=rnewman
authorMichael Comella <michael.l.comella@gmail.com>
Fri, 06 Dec 2013 11:43:10 -0800
changeset 174916 0c262d39810676c75b754c3dbd25c29b6424d624
parent 174915 11159bb95e5c97978119cc4658d6940d5f2c1a2a
child 174917 4c1017736f23b6137c6baa86ce04b34e513555d5
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs938827
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 938827 - Part 2: Call PanningPerfAPI directly. r=rnewman
build/mobile/robocop/FennecNativeDriver.java
mobile/android/base/RobocopAPI.java
mobile/android/base/gfx/PanningPerfAPI.java
--- a/build/mobile/robocop/FennecNativeDriver.java
+++ b/build/mobile/robocop/FennecNativeDriver.java
@@ -1,15 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
 import org.mozilla.gecko.gfx.LayerView;
+import org.mozilla.gecko.gfx.PanningPerfAPI;
 
 import java.io.BufferedOutputStream;
 import java.io.BufferedReader;
 import java.io.DataOutputStream;
 import java.io.File;
 import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.FileOutputStream;
@@ -48,20 +49,16 @@ public class FennecNativeDriver implemen
     private static String mLogFile = null;
     private static LogLevel mLogLevel = LogLevel.INFO;
 
     // Objects for reflexive access of fennec classes.
     private ClassLoader mClassLoader;
     private Class mApiClass;
     private Class mEventListenerClass;
     private Method mRegisterEventListener;
-    private Method mStartFrameRecording;
-    private Method mStopFrameRecording;
-    private Method mStartCheckerboardRecording;
-    private Method mStopCheckerboardRecording;
     private Object mRobocopApi;
 
     public enum LogLevel {
         DEBUG(1),
         INFO(2),
         WARN(3),
         ERROR(4);
 
@@ -88,20 +85,16 @@ public class FennecNativeDriver implemen
         // Set up reflexive access of java classes and methods.
         try {
             mClassLoader = activity.getClassLoader();
 
             mApiClass = mClassLoader.loadClass("org.mozilla.gecko.RobocopAPI");
             mEventListenerClass = mClassLoader.loadClass("org.mozilla.gecko.util.GeckoEventListener");
 
             mRegisterEventListener = mApiClass.getMethod("registerEventListener", String.class, mEventListenerClass);
-            mStartFrameRecording = mApiClass.getDeclaredMethod("startFrameTimeRecording");
-            mStopFrameRecording = mApiClass.getDeclaredMethod("stopFrameTimeRecording");
-            mStartCheckerboardRecording = mApiClass.getDeclaredMethod("startCheckerboardRecording");
-            mStopCheckerboardRecording = mApiClass.getDeclaredMethod("stopCheckerboardRecording");
 
             mRobocopApi = mApiClass.getConstructor(Activity.class).newInstance(activity);
         } catch (Exception e) {
             log(LogLevel.ERROR, e);
         }
     }
 
     //Information on the location of the Gecko Frame.
@@ -167,76 +160,48 @@ public class FennecNativeDriver implemen
             return new FennecNativeElement(Integer.decode((String)mLocators.get(name)), activity, mSolo);
         }
         FennecNativeDriver.log(FennecNativeDriver.LogLevel.ERROR,
             "findElement: Element '"+name+"' does not exist in the list");
         return null;
     }
 
     public void startFrameRecording() {
-        try {
-            mStartFrameRecording.invoke(null);
-        } catch (IllegalAccessException e) {
-            log(LogLevel.ERROR, e);
-        } catch (InvocationTargetException e) {
-            log(LogLevel.ERROR, e);
-        }
+        PanningPerfAPI.startFrameTimeRecording();
     }
 
     public int stopFrameRecording() {
-        try {
-            List<Long> frames = (List<Long>)mStopFrameRecording.invoke(null);
-            int badness = 0;
-            for (int i = 1; i < frames.size(); i++) {
-                long frameTime = frames.get(i) - frames.get(i - 1);
-                int delay = (int)(frameTime - FRAME_TIME_THRESHOLD);
-                // for each frame we miss, add the square of the delay. This
-                // makes large delays much worse than small delays.
-                if (delay > 0) {
-                    badness += delay * delay;
-                }
+        final List<Long> frames = PanningPerfAPI.stopFrameTimeRecording();
+        int badness = 0;
+        for (int i = 1; i < frames.size(); i++) {
+            long frameTime = frames.get(i) - frames.get(i - 1);
+            int delay = (int)(frameTime - FRAME_TIME_THRESHOLD);
+            // for each frame we miss, add the square of the delay. This
+            // makes large delays much worse than small delays.
+            if (delay > 0) {
+                badness += delay * delay;
             }
-            // Don't do any averaging of the numbers because really we want to
-            // know how bad the jank was at its worst
-            return badness;
-        } catch (IllegalAccessException e) {
-            log(LogLevel.ERROR, e);
-        } catch (InvocationTargetException e) {
-            log(LogLevel.ERROR, e);
         }
 
-        // higher values are worse, and the test failing is the worst!
-        return Integer.MAX_VALUE;
+        // Don't do any averaging of the numbers because really we want to
+        // know how bad the jank was at its worst
+        return badness;
     }
 
     public void startCheckerboardRecording() {
-        try {
-            mStartCheckerboardRecording.invoke(null);
-        } catch (IllegalAccessException e) {
-            log(LogLevel.ERROR, e);
-        } catch (InvocationTargetException e) {
-            log(LogLevel.ERROR, e);
-        }
+        PanningPerfAPI.startCheckerboardRecording();
     }
 
     public float stopCheckerboardRecording() {
-        try {
-            List<Float> checkerboard = (List<Float>)mStopCheckerboardRecording.invoke(null);
-            float total = 0;
-            for (float val : checkerboard) {
-                total += val;
-            }
-            return total * 100.0f;
-        } catch (IllegalAccessException e) {
-            log(LogLevel.ERROR, e);
-        } catch (InvocationTargetException e) {
-            log(LogLevel.ERROR, e);
+        final List<Float> checkerboard = PanningPerfAPI.stopCheckerboardRecording();
+        float total = 0;
+        for (float val : checkerboard) {
+            total += val;
         }
-
-        return 0.0f;
+        return total * 100.0f;
     }
 
     private LayerView getSurfaceView() {
         return mSolo.getView(LayerView.class, 0);
     }
 
     public PaintedSurface getPaintedSurface() {
         final LayerView view = getSurfaceView();
--- a/mobile/android/base/RobocopAPI.java
+++ b/mobile/android/base/RobocopAPI.java
@@ -1,16 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
 import org.mozilla.gecko.gfx.GeckoLayerClient;
-import org.mozilla.gecko.gfx.PanningPerfAPI;
 import org.mozilla.gecko.mozglue.GeckoLoader;
 import org.mozilla.gecko.mozglue.RobocopTarget;
 import org.mozilla.gecko.sqlite.SQLiteBridge;
 import org.mozilla.gecko.util.GeckoEventListener;
 
 import android.app.Activity;
 import android.database.Cursor;
 import android.view.View;
@@ -71,26 +70,9 @@ public class RobocopAPI {
     public void setDrawListener(GeckoLayerClient.DrawListener listener) {
         GeckoAppShell.getLayerView().getLayerClient().setDrawListener(listener);
     }
 
     public Cursor querySql(String dbPath, String query) {
         GeckoLoader.loadSQLiteLibs(mGeckoApp, mGeckoApp.getApplication().getPackageResourcePath());
         return new SQLiteBridge(dbPath).rawQuery(query, null);
     }
-
-    // PanningPerfAPI.
-    public static void startFrameTimeRecording() {
-        PanningPerfAPI.startFrameTimeRecording();
-    }
-
-    public static List<Long> stopFrameTimeRecording() {
-        return PanningPerfAPI.stopFrameTimeRecording();
-    }
-
-    public static void startCheckerboardRecording() {
-        PanningPerfAPI.startCheckerboardRecording();
-    }
-
-    public static List<Float> stopCheckerboardRecording() {
-        return PanningPerfAPI.stopCheckerboardRecording();
-    }
 }
--- a/mobile/android/base/gfx/PanningPerfAPI.java
+++ b/mobile/android/base/gfx/PanningPerfAPI.java
@@ -1,15 +1,17 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.gfx;
 
+import org.mozilla.gecko.mozglue.RobocopTarget;
+
 import android.os.SystemClock;
 import android.util.Log;
 
 import java.util.ArrayList;
 import java.util.List;
 
 public class PanningPerfAPI {
     private static final String LOGTAG = "GeckoPanningPerfAPI";
@@ -35,26 +37,28 @@ public class PanningPerfAPI {
         }
         if (mCheckerboardAmounts == null) {
             mCheckerboardAmounts = new ArrayList<Float>(EXPECTED_FRAME_COUNT);
         } else {
             mCheckerboardAmounts.clear();
         }
     }
 
+    @RobocopTarget
     public static void startFrameTimeRecording() {
         if (mRecordingFrames || mRecordingCheckerboard) {
             Log.e(LOGTAG, "Error: startFrameTimeRecording() called while already recording!");
             return;
         }
         mRecordingFrames = true;
         initialiseRecordingArrays();
         mFrameStartTime = SystemClock.uptimeMillis();
     }
 
+    @RobocopTarget
     public static List<Long> stopFrameTimeRecording() {
         if (!mRecordingFrames) {
             Log.e(LOGTAG, "Error: stopFrameTimeRecording() called when not recording!");
             return null;
         }
         mRecordingFrames = false;
         return mFrameTimes;
     }
@@ -65,26 +69,28 @@ public class PanningPerfAPI {
             mFrameTimes.add(SystemClock.uptimeMillis() - mFrameStartTime);
         }
     }
 
     public static boolean isRecordingCheckerboard() {
         return mRecordingCheckerboard;
     }
 
+    @RobocopTarget
     public static void startCheckerboardRecording() {
         if (mRecordingCheckerboard || mRecordingFrames) {
             Log.e(LOGTAG, "Error: startCheckerboardRecording() called while already recording!");
             return;
         }
         mRecordingCheckerboard = true;
         initialiseRecordingArrays();
         mCheckerboardStartTime = SystemClock.uptimeMillis();
     }
 
+    @RobocopTarget
     public static List<Float> stopCheckerboardRecording() {
         if (!mRecordingCheckerboard) {
             Log.e(LOGTAG, "Error: stopCheckerboardRecording() called when not recording!");
             return null;
         }
         mRecordingCheckerboard = false;
 
         // We take the number of values in mCheckerboardAmounts here, as there's