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

Commit 4e5c14f3 authored by Yury Khmel's avatar Yury Khmel Committed by Android (Google) Code Review
Browse files

Merge "Send status of Surface performance tests."

parents 978deb2e 9e433bba
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -106,12 +106,12 @@ public class SurfaceCompositionMeasuringActivity extends Activity implements OnC

    class CompositorScore {
        double mSurfaces;
        double mBitrate;
        double mBandwidth;

        @Override
        public String toString() {
            return DOUBLE_FORMAT.format(mSurfaces) + " surfaces. " +
                    "Bitrate: " + getReadableMemory((long)mBitrate) + "/s";
                    "Bandwidth: " + getReadableMemory((long)mBandwidth) + "/s";
        }
    }

@@ -131,7 +131,7 @@ public class SurfaceCompositionMeasuringActivity extends Activity implements OnC
        score.mSurfaces = measureCompositionScore(new Measurement(0, 60.0),
                new Measurement(mViews.size() + 1, 0.0f), pixelFormat);
        // Assume 32 bits per pixel.
        score.mBitrate = score.mSurfaces * mTargetFPS * mWidth * mHeight * 4.0;
        score.mBandwidth = score.mSurfaces * mTargetFPS * mWidth * mHeight * 4.0;
        //memAccessTask.stop();
        return score;
    }
+29 −0
Original line number Diff line number Diff line
@@ -15,7 +15,9 @@
 */
package android.surfacecomposition;

import android.app.Activity;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.surfacecomposition.SurfaceCompositionMeasuringActivity.AllocationScore;
import android.surfacecomposition.SurfaceCompositionMeasuringActivity.CompositorScore;
import android.test.ActivityInstrumentationTestCase2;
@@ -25,6 +27,16 @@ import android.util.Log;
public class SurfaceCompositionTest extends
        ActivityInstrumentationTestCase2<SurfaceCompositionMeasuringActivity> {
    private final static String TAG = "SurfaceCompositionTest";
    private final static String KEY_SURFACE_COMPOSITION_PERFORMANCE =
            "surface-compoistion-peformance-sps";
    private final static String KEY_SURFACE_COMPOSITION_BANDWITH =
            "surface-compoistion-bandwidth-gbps";
    private final static String KEY_SURFACE_ALLOCATION_PERFORMANCE_MEDIAN =
            "surface-allocation-performance-median-sps";
    private final static String KEY_SURFACE_ALLOCATION_PERFORMANCE_MIN =
            "surface-allocation-performance-min-sps";
    private final static String KEY_SURFACE_ALLOCATION_PERFORMANCE_MAX =
            "surface-allocation-performance-max-sps";

    // Pass threshold for major pixel formats.
    private final static int[] TEST_PIXEL_FORMATS = new int[] {
@@ -53,6 +65,7 @@ public class SurfaceCompositionTest extends

    @SmallTest
    public void testSurfaceCompositionPerformance() {
        Bundle status = new Bundle();
        for (int i = 0; i < TEST_PIXEL_FORMATS.length; ++i) {
            int pixelFormat = TEST_PIXEL_FORMATS[i];
            String formatName = SurfaceCompositionMeasuringActivity.getPixelFormatInfo(pixelFormat);
@@ -62,11 +75,20 @@ public class SurfaceCompositionTest extends
                    "performance score. " + score.mSurfaces + " < " +
                    MIN_ACCEPTED_COMPOSITION_SCORE[i] + ".",
                    score.mSurfaces >= MIN_ACCEPTED_COMPOSITION_SCORE[i]);
            // Send status only for TRANSLUCENT format.
            if (pixelFormat == PixelFormat.TRANSLUCENT) {
                status.putDouble(KEY_SURFACE_COMPOSITION_PERFORMANCE, score.mSurfaces);
                // Put bandwidth in GBPS.
                status.putDouble(KEY_SURFACE_COMPOSITION_BANDWITH, score.mBandwidth /
                        (1024.0 * 1024.0 * 1024.0));
            }
        }
        getInstrumentation().sendStatus(Activity.RESULT_OK, status);
    }

    @SmallTest
    public void testSurfaceAllocationPerformance() {
        Bundle status = new Bundle();
        for (int i = 0; i < TEST_PIXEL_FORMATS.length; ++i) {
            int pixelFormat = TEST_PIXEL_FORMATS[i];
            String formatName = SurfaceCompositionMeasuringActivity.getPixelFormatInfo(pixelFormat);
@@ -76,6 +98,13 @@ public class SurfaceCompositionTest extends
                    "performance score. " + score.mMedian + " < " +
                    MIN_ACCEPTED_ALLOCATION_SCORE[i] + ".",
                    score.mMedian >= MIN_ACCEPTED_ALLOCATION_SCORE[i]);
            // Send status only for TRANSLUCENT format.
            if (pixelFormat == PixelFormat.TRANSLUCENT) {
                status.putDouble(KEY_SURFACE_ALLOCATION_PERFORMANCE_MEDIAN, score.mMedian);
                status.putDouble(KEY_SURFACE_ALLOCATION_PERFORMANCE_MIN, score.mMin);
                status.putDouble(KEY_SURFACE_ALLOCATION_PERFORMANCE_MAX, score.mMax);
            }
        }
        getInstrumentation().sendStatus(Activity.RESULT_OK, status);
    }
}