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

Commit f45748d4 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add Bitmap#asShared() PerfTest" into main

parents 7214dca1 c21b8a00
Loading
Loading
Loading
Loading
+22 −7
Original line number Original line Diff line number Diff line
@@ -36,13 +36,7 @@ public class BitmapPerfTest {
    @Test
    @Test
    public void testParcelBitmap() {
    public void testParcelBitmap() {
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();

        final Bitmap bitmap = makeBitmap();
        // 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"));


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


        bitmap.recycle();
        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;
    }
}
}