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

Commit c21b8a00 authored by Shai Barack's avatar Shai Barack
Browse files

Add Bitmap#asShared() PerfTest

Flag: EXEMPT test-only
Change-Id: I14785c1efb7f2a3f6b475c3fe042731402c6a877
parent 39a01742
Loading
Loading
Loading
Loading
+22 −7
Original line number Diff line number Diff line
@@ -36,13 +36,7 @@ public class BitmapPerfTest {
    @Test
    public void testParcelBitmap() {
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();

        // Make a large enough bitmap to be a good benchmark.
        Bitmap bitmap = Bitmap.createBitmap(1000, 1000, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        // Paint the canvas purple.
        // Purple is a good color for a benchmark. Purple benchmarks are the best.
        canvas.drawColor(Color.parseColor("purple"));
        final Bitmap bitmap = makeBitmap();

        while (state.keepRunning()) {
            Parcel parcel = Parcel.obtain();
@@ -52,4 +46,25 @@ public class BitmapPerfTest {

        bitmap.recycle();
    }

    @Test
    public void testBitmapAsShared() {
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final Bitmap bitmap = makeBitmap();

        while (state.keepRunning()) {
            Bitmap unused = bitmap.asShared();
        }

        bitmap.recycle();
    }

    private Bitmap makeBitmap() {
        Bitmap bitmap = Bitmap.createBitmap(1000, 1000, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        // Paint the canvas purple.
        // Purple is a good color for a benchmark. Purple benchmarks are the best.
        canvas.drawColor(Color.parseColor("purple"));
        return bitmap;
    }
}