Extend existing R8 benchmarks with R8 partial

Change-Id: I98dd33933322c15cad8efe12db7f7738fde02b19
diff --git a/src/test/java/com/android/tools/r8/benchmarks/appdumps/AppDumpBenchmarkBuilder.java b/src/test/java/com/android/tools/r8/benchmarks/appdumps/AppDumpBenchmarkBuilder.java
index 1ea5acf..bd3609b 100644
--- a/src/test/java/com/android/tools/r8/benchmarks/appdumps/AppDumpBenchmarkBuilder.java
+++ b/src/test/java/com/android/tools/r8/benchmarks/appdumps/AppDumpBenchmarkBuilder.java
@@ -147,12 +147,17 @@
   }
 
   public BenchmarkConfig buildR8WithPartialShrinking() {
+    return buildR8WithPartialShrinking(getDefaultR8PartialConfiguration());
+  }
+
+  public BenchmarkConfig buildR8WithPartialShrinking(
+      ThrowableConsumer<? super R8PartialTestBuilder> configuration) {
     verify();
     return BenchmarkConfig.builder()
         .setName(name)
         .setTarget(BenchmarkTarget.R8)
         .setSuite(BenchmarkSuite.OPENSOURCE_BENCHMARKS)
-        .setMethod(runR8WithPartialShrinking(this))
+        .setMethod(runR8WithPartialShrinking(this, configuration))
         .setFromRevision(fromRevision)
         .addDependency(dumpDependency)
         .measureRunTime()
@@ -307,8 +312,10 @@
     return internalRunR8(builder, false, configuration);
   }
 
-  private static BenchmarkMethod runR8WithPartialShrinking(AppDumpBenchmarkBuilder builder) {
-    return internalRunR8Partial(builder, getDefaultR8PartialConfiguration());
+  private static BenchmarkMethod runR8WithPartialShrinking(
+      AppDumpBenchmarkBuilder builder,
+      ThrowableConsumer<? super R8PartialTestBuilder> configuration) {
+    return internalRunR8Partial(builder, configuration);
   }
 
   private static BenchmarkMethod runR8WithResourceShrinking(
@@ -402,7 +409,15 @@
                       // TODO(b/388452773): Fix support for default interface methods.
                       .setMinApi(Math.max(dumpProperties.getMinApi(), AndroidApiLevel.N.getLevel()))
                       .setR8PartialConfiguration(
-                          b -> builder.programPackages.forEach(b::addJavaTypeIncludePattern))
+                          b -> {
+                            if (builder.programPackages.isEmpty()) {
+                              b.addJavaTypeIncludePattern("androidx.**");
+                              b.addJavaTypeIncludePattern("kotlin.**");
+                              b.addJavaTypeIncludePattern("kotlinx.**");
+                            } else {
+                              builder.programPackages.forEach(b::addJavaTypeIncludePattern);
+                            }
+                          })
                       .apply(b -> addDesugaredLibrary(b, dump))
                       .apply(configuration)
                       .applyIf(
diff --git a/src/test/java/com/android/tools/r8/benchmarks/appdumps/ComposeSamplesBenchmarks.java b/src/test/java/com/android/tools/r8/benchmarks/appdumps/ComposeSamplesBenchmarks.java
index dd95d2d..14b8f7e 100644
--- a/src/test/java/com/android/tools/r8/benchmarks/appdumps/ComposeSamplesBenchmarks.java
+++ b/src/test/java/com/android/tools/r8/benchmarks/appdumps/ComposeSamplesBenchmarks.java
@@ -4,6 +4,7 @@
 package com.android.tools.r8.benchmarks.appdumps;
 
 import com.android.tools.r8.R8FullTestBuilder;
+import com.android.tools.r8.R8PartialTestBuilder;
 import com.android.tools.r8.TestParameters;
 import com.android.tools.r8.ToolHelper;
 import com.android.tools.r8.benchmarks.BenchmarkBase;
@@ -41,40 +42,80 @@
             .setFromRevision(16457)
             .buildR8(),
         AppDumpBenchmarkBuilder.builder()
+            .setName("CraneAppPartial")
+            .setDumpDependencyPath(dir.resolve("crane"))
+            .setFromRevision(16457)
+            .buildR8WithPartialShrinking(),
+        AppDumpBenchmarkBuilder.builder()
             .setName("JetLaggedApp")
             .setDumpDependencyPath(dir.resolve("jetlagged"))
             .setFromRevision(16457)
             .buildR8(),
         AppDumpBenchmarkBuilder.builder()
+            .setName("JetLaggedAppPartial")
+            .setDumpDependencyPath(dir.resolve("jetlagged"))
+            .setFromRevision(16457)
+            .buildR8WithPartialShrinking(),
+        AppDumpBenchmarkBuilder.builder()
             .setName("JetNewsApp")
             .setDumpDependencyPath(dir.resolve("jetnews"))
             .setFromRevision(16457)
             .buildR8(),
         AppDumpBenchmarkBuilder.builder()
+            .setName("JetNewsAppPartial")
+            .setDumpDependencyPath(dir.resolve("jetnews"))
+            .setFromRevision(16457)
+            .buildR8WithPartialShrinking(),
+        AppDumpBenchmarkBuilder.builder()
             .setName("JetCasterApp")
             .setDumpDependencyPath(dir.resolve("jetcaster"))
             .setFromRevision(16457)
             .buildR8(ComposeSamplesBenchmarks::configureJetCasterApp),
         AppDumpBenchmarkBuilder.builder()
+            .setName("JetCasterAppPartial")
+            .setDumpDependencyPath(dir.resolve("jetcaster"))
+            .setFromRevision(16457)
+            .buildR8WithPartialShrinking(ComposeSamplesBenchmarks::configureJetCasterAppPartial),
+        AppDumpBenchmarkBuilder.builder()
             .setName("JetChatApp")
             .setDumpDependencyPath(dir.resolve("jetchat"))
             .setFromRevision(16457)
             .buildR8(ComposeSamplesBenchmarks::configureJetChatApp),
         AppDumpBenchmarkBuilder.builder()
+            .setName("JetChatAppPartial")
+            .setDumpDependencyPath(dir.resolve("jetchat"))
+            .setFromRevision(16457)
+            .buildR8WithPartialShrinking(ComposeSamplesBenchmarks::configureJetChatAppPartial),
+        AppDumpBenchmarkBuilder.builder()
             .setName("JetSnackApp")
             .setDumpDependencyPath(dir.resolve("jetsnack"))
             .setFromRevision(16457)
             .buildR8(),
         AppDumpBenchmarkBuilder.builder()
+            .setName("JetSnackAppPartial")
+            .setDumpDependencyPath(dir.resolve("jetsnack"))
+            .setFromRevision(16457)
+            .buildR8WithPartialShrinking(),
+        AppDumpBenchmarkBuilder.builder()
             .setName("OwlApp")
             .setDumpDependencyPath(dir.resolve("owl"))
             .setFromRevision(16457)
             .buildR8(),
         AppDumpBenchmarkBuilder.builder()
+            .setName("OwlAppPartial")
+            .setDumpDependencyPath(dir.resolve("owl"))
+            .setFromRevision(16457)
+            .buildR8WithPartialShrinking(),
+        AppDumpBenchmarkBuilder.builder()
             .setName("ReplyApp")
             .setDumpDependencyPath(dir.resolve("reply"))
             .setFromRevision(16457)
-            .buildR8());
+            .buildR8(),
+        AppDumpBenchmarkBuilder.builder()
+            .setName("ReplyAppPartial")
+            .setDumpDependencyPath(dir.resolve("reply"))
+            .setFromRevision(16457)
+            .buildR8WithPartialShrinking());
   }
 
   private static void configureJetCasterApp(R8FullTestBuilder testBuilder) {
@@ -100,6 +141,14 @@
             });
   }
 
+  private static void configureJetCasterAppPartial(R8PartialTestBuilder testBuilder) {
+    testBuilder
+        .allowDiagnosticInfoMessages()
+        .allowUnnecessaryDontWarnWildcards()
+        .allowUnusedDontWarnPatterns()
+        .allowUnusedProguardConfigurationRules();
+  }
+
   private static void configureJetChatApp(R8FullTestBuilder testBuilder) {
     testBuilder
         .allowDiagnosticInfoMessages()
@@ -108,6 +157,14 @@
         .allowUnusedProguardConfigurationRules();
   }
 
+  private static void configureJetChatAppPartial(R8PartialTestBuilder testBuilder) {
+    testBuilder
+        .allowDiagnosticInfoMessages()
+        .allowUnnecessaryDontWarnWildcards()
+        .allowUnusedDontWarnPatterns()
+        .allowUnusedProguardConfigurationRules();
+  }
+
   @Ignore
   @Test
   @Override
@@ -121,37 +178,77 @@
   }
 
   @Test
+  public void testCraneAppPartial() throws Exception {
+    testBenchmarkWithName("CraneAppPartial");
+  }
+
+  @Test
   public void testJetLaggedApp() throws Exception {
     testBenchmarkWithName("JetLaggedApp");
   }
 
   @Test
+  public void testJetLaggedAppPartial() throws Exception {
+    testBenchmarkWithName("JetLaggedAppPartial");
+  }
+
+  @Test
   public void testJetNewsApp() throws Exception {
     testBenchmarkWithName("JetNewsApp");
   }
 
   @Test
+  public void testJetNewsAppPartial() throws Exception {
+    testBenchmarkWithName("JetNewsAppPartial");
+  }
+
+  @Test
   public void testJetCasterApp() throws Exception {
     testBenchmarkWithName("JetCasterApp");
   }
 
   @Test
+  public void testJetCasterAppPartial() throws Exception {
+    testBenchmarkWithName("JetCasterAppPartial");
+  }
+
+  @Test
   public void testJetChatApp() throws Exception {
     testBenchmarkWithName("JetChatApp");
   }
 
   @Test
+  public void testJetChatAppPartial() throws Exception {
+    testBenchmarkWithName("JetChatAppPartial");
+  }
+
+  @Test
   public void testJetSnackApp() throws Exception {
     testBenchmarkWithName("JetSnackApp");
   }
 
   @Test
+  public void testJetSnackAppPartial() throws Exception {
+    testBenchmarkWithName("JetSnackAppPartial");
+  }
+
+  @Test
   public void testOwlApp() throws Exception {
     testBenchmarkWithName("OwlApp");
   }
 
   @Test
+  public void testOwlAppPartial() throws Exception {
+    testBenchmarkWithName("OwlAppPartial");
+  }
+
+  @Test
   public void testReplyApp() throws Exception {
     testBenchmarkWithName("ReplyApp");
   }
+
+  @Test
+  public void testReplyAppPartial() throws Exception {
+    testBenchmarkWithName("ReplyAppPartial");
+  }
 }
diff --git a/src/test/java/com/android/tools/r8/benchmarks/appdumps/NowInAndroidBenchmarks.java b/src/test/java/com/android/tools/r8/benchmarks/appdumps/NowInAndroidBenchmarks.java
index 9ed646a..5a7bc57 100644
--- a/src/test/java/com/android/tools/r8/benchmarks/appdumps/NowInAndroidBenchmarks.java
+++ b/src/test/java/com/android/tools/r8/benchmarks/appdumps/NowInAndroidBenchmarks.java
@@ -82,7 +82,6 @@
         AppDumpBenchmarkBuilder.builder()
             .setName("NowInAndroidAppPartial")
             .setDumpDependencyPath(dump)
-            .addProgramPackages("androidx.**", "kotlin.**", "kotlinx.**")
             .setFromRevision(16017)
             .buildR8WithPartialShrinking(),
         AppDumpBenchmarkBuilder.builder()
diff --git a/src/test/java/com/android/tools/r8/benchmarks/appdumps/TiviBenchmarks.java b/src/test/java/com/android/tools/r8/benchmarks/appdumps/TiviBenchmarks.java
index cdb523f..4814558 100644
--- a/src/test/java/com/android/tools/r8/benchmarks/appdumps/TiviBenchmarks.java
+++ b/src/test/java/com/android/tools/r8/benchmarks/appdumps/TiviBenchmarks.java
@@ -4,6 +4,7 @@
 package com.android.tools.r8.benchmarks.appdumps;
 
 import com.android.tools.r8.CompilationMode;
+import com.android.tools.r8.R8PartialTestBuilder;
 import com.android.tools.r8.TestParameters;
 import com.android.tools.r8.ToolHelper;
 import com.android.tools.r8.benchmarks.BenchmarkBase;
@@ -49,6 +50,20 @@
             .setCompilationMode(CompilationMode.DEBUG)
             .setFromRevision(12370)
             .addProgramPackages("app/tivi")
-            .buildIncrementalD8());
+            .buildIncrementalD8(),
+        AppDumpBenchmarkBuilder.builder()
+            .setName("TiviAppPartial")
+            .setDumpDependencyPath(dump)
+            .setFromRevision(12215)
+            .buildR8WithPartialShrinking(TiviBenchmarks::configureR8Partial));
+  }
+
+  private static void configureR8Partial(R8PartialTestBuilder testBuilder) {
+    testBuilder
+        .allowUnnecessaryDontWarnWildcards()
+        .allowUnusedDontWarnPatterns()
+        .allowUnusedProguardConfigurationRules()
+        // TODO(b/222228826): Disallow unrecognized diagnostics and open interfaces.
+        .allowDiagnosticMessages();
   }
 }