Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 62c7b375 authored by Chris Craik's avatar Chris Craik Committed by Android (Google) Code Review
Browse files

Merge "Added automated performance test to TileBenchmark"

parents 44156291 555c55ed
Loading
Loading
Loading
Loading
+18 −7
Original line number Diff line number Diff line
@@ -8405,9 +8405,9 @@ public class WebView extends AbsoluteLayout
        }
    }

    // Called by JNI to invalidate the View, given rectangle coordinates in
    // content space
    private void pageSwapCallback() {
    /** @hide Called by JNI when pages are swapped (only occurs with hardware
     * acceleration) */
    protected void pageSwapCallback() {
        if (inEditingMode()) {
            didUpdateWebTextViewDimensions(ANYWHERE);
        }
@@ -8426,11 +8426,11 @@ public class WebView extends AbsoluteLayout
        WebViewCore.ViewState viewState = draw.mViewState;
        boolean isPictureAfterFirstLayout = viewState != null;

        if (updateBaseLayer) {
            // Request a callback on pageSwap (to reposition the webtextview)
            boolean registerPageSwapCallback =
                !mZoomManager.isFixedLengthAnimationInProgress() && inEditingMode();

        if (updateBaseLayer) {
            setBaseLayer(draw.mBaseLayer, draw.mInvalRegion,
                    getSettings().getShowVisualIndicator(),
                    isPictureAfterFirstLayout, registerPageSwapCallback);
@@ -9084,6 +9084,16 @@ public class WebView extends AbsoluteLayout
        }
    }

    /** @hide send content invalidate */
    protected void contentInvalidateAll() {
        mWebViewCore.sendMessage(EventHub.CONTENT_INVALIDATE_ALL);
    }

    /** @hide call pageSwapCallback upon next page swap */
    protected void registerPageSwapCallback() {
        nativeRegisterPageSwapCallback();
    }

    /**
     * Begin collecting per-tile profiling data
     *
@@ -9245,6 +9255,7 @@ public class WebView extends AbsoluteLayout
    private native void     nativeStopGL();
    private native Rect     nativeSubtractLayers(Rect content);
    private native int      nativeTextGeneration();
    private native void     nativeRegisterPageSwapCallback();
    private native void     nativeTileProfilingStart();
    private native float    nativeTileProfilingStop();
    private native void     nativeTileProfilingClear();
+5 −0
Original line number Diff line number Diff line
@@ -999,6 +999,7 @@ public final class WebViewCore {
        static final int DUMP_V8COUNTERS = 173;

        static final int SET_JS_FLAGS = 174;
        static final int CONTENT_INVALIDATE_ALL = 175;
        // Geolocation
        static final int GEOLOCATION_PERMISSIONS_PROVIDE = 180;

@@ -1503,6 +1504,10 @@ public final class WebViewCore {
                            nativeSetJsFlags((String)msg.obj);
                            break;

                        case CONTENT_INVALIDATE_ALL:
                            nativeContentInvalidateAll();
                            break;

                        case SAVE_WEBARCHIVE:
                            WebView.SaveWebArchiveMessage saveMessage =
                                (WebView.SaveWebArchiveMessage)msg.obj;
+8 −0
Original line number Diff line number Diff line
@@ -71,8 +71,16 @@
    <string name="frames_per_second">Frames/sec</string>
    <!-- Portion of viewport covered by good tiles [CHAR LIMIT=15] -->
    <string name="viewport_coverage">Coverage</string>
    <!-- Milliseconds taken to inval, and re-render the page [CHAR LIMIT=15] -->
    <string name="render_millis">RenderMillis</string>
    <!-- Format string for stat value overlay [CHAR LIMIT=15] -->
    <string name="format_stat">%4.4f</string>

    <!-- Format string for viewport position value overlay [CHAR LIMIT=25] -->
    <string name="format_view_pos">View:(%1$d,%2$d)-(%3$d,%4$d)</string>
    <!-- Format string for viewport position value overlay [CHAR LIMIT=25] -->
    <string name="format_inval_pos">Inval:(%1$d,%2$d)-(%3$d,%4$d)</string>

    <!-- Format string for displaying aggregate stats+values (nr of valid tiles,
    etc.) [CHAR LIMIT=20] -->
    <string name="format_stat_name">%1$-20s %2$3d</string>
+6 −6
Original line number Diff line number Diff line
@@ -83,14 +83,14 @@ public class PlaybackActivity extends Activity {
        }
    };

    private class LoadFileTask extends AsyncTask<String, Void, TileData[][]> {
    private class LoadFileTask extends AsyncTask<String, Void, RunData> {
        @Override
        protected TileData[][] doInBackground(String... params) {
            TileData[][] data = null;
        protected RunData doInBackground(String... params) {
            RunData data = null;
            try {
                FileInputStream fis = openFileInput(params[0]);
                ObjectInputStream in = new ObjectInputStream(fis);
                data = (TileData[][]) in.readObject();
                data = (RunData) in.readObject();
                in.close();
            } catch (IOException ex) {
                ex.printStackTrace();
@@ -101,7 +101,7 @@ public class PlaybackActivity extends Activity {
        }

        @Override
        protected void onPostExecute(TileData data[][]) {
        protected void onPostExecute(RunData data) {
            if (data == null) {
                Toast.makeText(getApplicationContext(),
                        getResources().getString(R.string.error_no_data),
@@ -110,7 +110,7 @@ public class PlaybackActivity extends Activity {
            }
            mPlaybackView.setData(data);

            mFrameMax = data.length - 1;
            mFrameMax = data.frames.length - 1;
            mSeekBar.setMax(mFrameMax);

            setFrame(null, 0);
+21 −33
Original line number Diff line number Diff line
@@ -22,10 +22,12 @@ import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.ShapeDrawable;
import android.os.Bundle;

import com.test.tilebenchmark.RunData.TileData;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

public class PlaybackGraphs {
    private static final int BAR_WIDTH = PlaybackView.TILE_SCALE * 3;
@@ -44,7 +46,7 @@ public class PlaybackGraphs {
        return 0.0f;
    }

    private interface MetricGen {
    protected interface MetricGen {
        public double getValue(TileData[] frame);

        public double getMax();
@@ -52,7 +54,7 @@ public class PlaybackGraphs {
        public int getLabelId();
    };

    private static MetricGen[] Metrics = new MetricGen[] {
    protected static MetricGen[] Metrics = new MetricGen[] {
            new MetricGen() {
                // framerate graph
                @Override
@@ -99,7 +101,7 @@ public class PlaybackGraphs {
            }
    };

    private interface StatGen {
    protected interface StatGen {
        public double getValue(double sortedValues[]);

        public int getLabelId();
@@ -116,7 +118,7 @@ public class PlaybackGraphs {
                + sortedValues[intIndex + 1] * (alpha);
    }

    private static StatGen[] Stats = new StatGen[] {
    protected static StatGen[] Stats = new StatGen[] {
            new StatGen() {
                @Override
                public double getValue(double[] sortedValues) {
@@ -157,21 +159,22 @@ public class PlaybackGraphs {
    }

    private ArrayList<ShapeDrawable> mShapes = new ArrayList<ShapeDrawable>();
    private double[][] mStats = new double[Metrics.length][Stats.length];
    protected double[][] mStats = new double[Metrics.length][Stats.length];
    protected HashMap<String, Double> mSingleStats;

    public void setData(TileData[][] tileProfilingData) {
    public void setData(RunData data) {
        mShapes.clear();
        double metricValues[] = new double[tileProfilingData.length];
        double metricValues[] = new double[data.frames.length];

        if (tileProfilingData.length == 0) {
        if (data.frames.length == 0) {
            return;
        }

        for (int metricIndex = 0; metricIndex < Metrics.length; metricIndex++) {
            // create graph out of rectangles, one per frame
            int lastBar = 0;
            for (int frameIndex = 0; frameIndex < tileProfilingData.length; frameIndex++) {
                TileData frame[] = tileProfilingData[frameIndex];
            for (int frameIndex = 0; frameIndex < data.frames.length; frameIndex++) {
                TileData frame[] = data.frames[frameIndex];
                int newBar = (frame[0].top + frame[0].bottom) / 2;

                MetricGen s = Metrics[metricIndex];
@@ -194,9 +197,11 @@ public class PlaybackGraphs {
            // store aggregate statistics per metric (median, and similar)
            Arrays.sort(metricValues);
            for (int statIndex = 0; statIndex < Stats.length; statIndex++) {
                mStats[metricIndex][statIndex] = Stats[statIndex]
                        .getValue(metricValues);
                mStats[metricIndex][statIndex] =
                        Stats[statIndex].getValue(metricValues);
            }

            mSingleStats = data.singleStats;
        }
    }

@@ -215,7 +220,7 @@ public class PlaybackGraphs {
    }

    public void draw(Canvas canvas, ArrayList<ShapeDrawable> shapes,
            String[] strings, Resources resources) {
            ArrayList<String> strings, Resources resources) {
        canvas.scale(CANVAS_SCALE, CANVAS_SCALE);

        canvas.translate(BAR_WIDTH * Metrics.length, 0);
@@ -238,26 +243,9 @@ public class PlaybackGraphs {
                canvas.drawText(label, xPos, yPos, whiteLabels);
            }
        }
        for (int stringIndex = 0; stringIndex < strings.length; stringIndex++) {
        for (int stringIndex = 0; stringIndex < strings.size(); stringIndex++) {
            int yPos = LABELOFFSET + stringIndex * PlaybackView.TILE_SCALE / 2;
            canvas.drawText(strings[stringIndex], 0, yPos, whiteLabels);
        }
            canvas.drawText(strings.get(stringIndex), 0, yPos, whiteLabels);
        }

    public Bundle getStatBundle(Resources resources) {
        Bundle b = new Bundle();

        for (int metricIndex = 0; metricIndex < Metrics.length; metricIndex++) {
            for (int statIndex = 0; statIndex < Stats.length; statIndex++) {
                String metricLabel = resources.getString(
                        Metrics[metricIndex].getLabelId());
                String statLabel = resources.getString(
                        Stats[statIndex].getLabelId());
                double value = mStats[metricIndex][statIndex];
                b.putDouble(metricLabel + " " + statLabel, value);
            }
        }

        return b;
    }
}
Loading