Loading apct-tests/perftests/core/src/android/graphics/perftests/BitmapPerfTest.java +22 −7 Original line number Original line Diff line number Diff line Loading @@ -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(); Loading @@ -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; } } } Loading
apct-tests/perftests/core/src/android/graphics/perftests/BitmapPerfTest.java +22 −7 Original line number Original line Diff line number Diff line Loading @@ -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(); Loading @@ -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; } } }