Experimental R8 support in microbenchmarks
Off by default in the AndroidX repo, but can be experimentally used by
external. As this isn't run in presubmit/postsubmit, it may require
adding additional rules for any specific test.
```
(androidTest.enableMinification = false)
840,772 ns 389 allocs Trace LazyListScrollingBenchmark.scrollProgrammatically_newItemComposed[LazyColumn]
837,786 ns 389 allocs Trace LazyListScrollingBenchmark.scrollProgrammatically_newItemComposed[LazyRow]
(androidTest.enableMinification = true)
658,050 ns 390 allocs Trace LazyListScrollingBenchmark.scrollProgrammatically_newItemComposed[LazyColumn]
651,393 ns 390 allocs Trace LazyListScrollingBenchmark.scrollProgrammatically_newItemComposed[LazyRow]
```
(Mokey, locked clocks)
Test: LazyListScrollingBenchmark.scrollProgrammatically_newItemComposed
Fixes: 184378053
Relnote: """Experimental R8 support in microbench via embedded proguard
rules. Note that this support is experimental, and requires AGP 8.3
for minification of library module tests. Use the following to enable
in your benchmark module's `build.gradle`:
```
android {
buildTypes.release.androidTest.enableMinification = true
}
```
"""
Change-Id: I738a3294c5ded7b336ed0f49d0615eb9231cce51
diff --git a/benchmark/benchmark-junit4/proguard-rules.pro b/benchmark/benchmark-junit4/proguard-rules.pro
new file mode 100644
index 0000000..507b097
--- /dev/null
+++ b/benchmark/benchmark-junit4/proguard-rules.pro
@@ -0,0 +1,18 @@
+## These rules enable microbenchmarking from a minified test, as an experimental feature
+
+# basic protection against junit/androidx.test reflection, shouldn't affect library/test code
+-keepclasseswithmembers class androidx.test.** { *; }
+-keepclasseswithmembers class org.junit.** { *; }
+-keepclasseswithmembers class junit.** { *; }
+-dontwarn com.google.errorprone.annotations.MustBeClosed
+
+## keep test classes
+-keepclasseswithmembers @org.junit.runner.RunWith class * { *; }
+
+## needed for org.junit.Test annotation to be discoverable by reflection
+-keepattributes *Annotation*
+
+## Needed due to b/328649293 - shouldn't be needed since they're ref'd by manifest
+## May need to leave these in place long term to account for old gradle versions
+-keepclasseswithmembers class androidx.benchmark.junit4.AndroidBenchmarkRunner { *; }
+-keepclasseswithmembers class androidx.benchmark.IsolationActivity { *; }