Add SystemUI benchmarks for running locally

Change-Id: I1c3c6212836fb4e7afd337e188be96a70cc6af54
diff --git a/.gitignore b/.gitignore
index ad943a3..b62cc8f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -44,6 +44,8 @@
 third_party/android_cts_baseline.tar.gz
 third_party/clank/clank_google3_prebuilt
 third_party/clank/clank_google3.tar.gz
+third_party/closedsource-apps/systemui
+third_party/closedsource-apps/systemui.tar.gz
 third_party/android_jar/lib
 third_party/android_jar/lib-v[0-9][0-9]
 third_party/android_jar/lib-v[0-9][0-9].tar.gz
diff --git a/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt b/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt
index 1154694..0f59b8b 100644
--- a/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt
+++ b/d8_r8/commonBuildSrc/src/main/kotlin/DependenciesPlugin.kt
@@ -763,6 +763,11 @@
     "smali",
     Paths.get("third_party", "smali").toFile(),
     Paths.get("third_party", "smali.tar.gz.sha1").toFile())
+  val systemUI = ThirdPartyDependency(
+    "systemUI",
+    Paths.get("third_party", "closedsource-apps", "systemui").toFile(),
+    Paths.get("third_party", "closedsource-apps", "systemui.tar.gz.sha1").toFile(),
+    DependencyType.X20)
   val tivi = ThirdPartyDependency(
     "tivi",
     Paths.get("third_party", "opensource-apps", "tivi").toFile(),
diff --git a/src/test/java/com/android/tools/r8/benchmarks/BenchmarkCollection.java b/src/test/java/com/android/tools/r8/benchmarks/BenchmarkCollection.java
index e3612a0..1d2a77b 100644
--- a/src/test/java/com/android/tools/r8/benchmarks/BenchmarkCollection.java
+++ b/src/test/java/com/android/tools/r8/benchmarks/BenchmarkCollection.java
@@ -8,6 +8,7 @@
 import com.android.tools.r8.benchmarks.appdumps.ChromeBenchmarks;
 import com.android.tools.r8.benchmarks.appdumps.ComposeSamplesBenchmarks;
 import com.android.tools.r8.benchmarks.appdumps.NowInAndroidBenchmarks;
+import com.android.tools.r8.benchmarks.appdumps.SystemUIBenchmarks;
 import com.android.tools.r8.benchmarks.appdumps.TiviBenchmarks;
 import com.android.tools.r8.benchmarks.desugaredlib.L8Benchmark;
 import com.android.tools.r8.benchmarks.helloworld.HelloWorldBenchmark;
@@ -68,7 +69,8 @@
         TiviBenchmarks.configs(),
         RetraceStackTraceBenchmark.configs(),
         ComposeSamplesBenchmarks.configs(),
-        ChromeBenchmarks.configs());
+        ChromeBenchmarks.configs(),
+        SystemUIBenchmarks.configs());
   }
 
   /** Compute and print the golem configuration. */
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 de6dd63..aa229d1 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
@@ -3,7 +3,6 @@
 // BSD-style license that can be found in the LICENSE file.
 package com.android.tools.r8.benchmarks.appdumps;
 
-import static junit.framework.TestCase.assertFalse;
 
 import com.android.tools.r8.LibraryDesugaringTestConfiguration;
 import com.android.tools.r8.R8FullTestBuilder;
@@ -135,17 +134,20 @@
   }
 
   public BenchmarkConfig buildR8WithResourceShrinking() {
+    return buildR8WithResourceShrinking(getDefaultR8Configuration());
+  }
+
+  public BenchmarkConfig buildR8WithResourceShrinking(
+      ThrowableConsumer<? super R8FullTestBuilder> configuration) {
     verify();
     return BenchmarkConfig.builder()
         .setName(name)
         .setTarget(BenchmarkTarget.R8)
         .setSuite(BenchmarkSuite.OPENSOURCE_BENCHMARKS)
-        .setMethod(runR8WithResourceShrinking(this, getDefaultR8Configuration()))
+        .setMethod(runR8WithResourceShrinking(this, configuration))
         .setFromRevision(fromRevision)
         .addDependency(dumpDependency)
-        .addSubBenchmark(nameForCodePart(), BenchmarkMetric.CodeSize)
-        .addSubBenchmark(nameForRuntimePart(), BenchmarkMetric.RunTimeRaw)
-        .addSubBenchmark(nameForResourcePart(), BenchmarkMetric.CodeSize)
+        .measureRunTime()
         .setTimeout(10, TimeUnit.MINUTES)
         .build();
   }
@@ -299,11 +301,11 @@
                       .applyIf(
                           enableResourceShrinking,
                           r -> {
-                            assertFalse(environment.getConfig().containsComposableCodeSizeMetric());
-                            r.benchmarkCompile(results.getSubResults(builder.nameForRuntimePart()))
-                                .benchmarkCodeSize(results.getSubResults(builder.nameForCodePart()))
-                                .benchmarkResourceSize(
-                                    results.getSubResults(builder.nameForResourcePart()));
+                            try {
+                              r.benchmarkCompile(results);
+                            } catch (Exception e) {
+                              // Ignore.
+                            }
                           },
                           r ->
                               r.benchmarkCompile(results)
diff --git a/src/test/java/com/android/tools/r8/benchmarks/appdumps/SystemUIBenchmarks.java b/src/test/java/com/android/tools/r8/benchmarks/appdumps/SystemUIBenchmarks.java
new file mode 100644
index 0000000..a77ee5f
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/benchmarks/appdumps/SystemUIBenchmarks.java
@@ -0,0 +1,69 @@
+// Copyright (c) 2024, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8.benchmarks.appdumps;
+
+import com.android.tools.r8.R8FullTestBuilder;
+import com.android.tools.r8.TestParameters;
+import com.android.tools.r8.ToolHelper;
+import com.android.tools.r8.benchmarks.BenchmarkBase;
+import com.android.tools.r8.benchmarks.BenchmarkConfig;
+import com.google.common.collect.ImmutableList;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class SystemUIBenchmarks extends BenchmarkBase {
+
+  private static final Path dir =
+      Paths.get(ToolHelper.THIRD_PARTY_DIR, "closedsource-apps/systemui");
+
+  public SystemUIBenchmarks(BenchmarkConfig config, TestParameters parameters) {
+    super(config, parameters);
+  }
+
+  @Parameters(name = "{0}")
+  public static List<Object[]> data() {
+    return parametersFromConfigs(configs());
+  }
+
+  public static List<BenchmarkConfig> configs() {
+    return ImmutableList.of(
+        AppDumpBenchmarkBuilder.builder()
+            .setName("SystemUIApp")
+            .setDumpDependencyPath(dir)
+            .setFromRevision(16457)
+            .buildR8WithResourceShrinking(SystemUIBenchmarks::configure),
+        AppDumpBenchmarkBuilder.builder()
+            .setName("SystemUIAppTreeShaking")
+            .setDumpDependencyPath(dir)
+            .setFromRevision(16457)
+            .buildR8WithResourceShrinking(SystemUIBenchmarks::configureTreeShaking));
+  }
+
+  private static void configure(R8FullTestBuilder testBuilder) {
+    testBuilder
+        .addDontWarn("android.hardware.graphics.common.DisplayDecorationSupport")
+        .addOptionsModification(
+            options -> options.getOpenClosedInterfacesOptions().suppressAllOpenInterfaces())
+        .allowDiagnosticMessages()
+        .allowUnusedDontWarnPatterns()
+        .allowUnusedProguardConfigurationRules()
+        .allowUnnecessaryDontWarnWildcards()
+        .setAndroidPlatformBuild();
+  }
+
+  private static void configureTreeShaking(R8FullTestBuilder testBuilder) {
+    configure(testBuilder);
+    testBuilder.addOptionsModification(
+        options ->
+            options.getTestingOptions().enqueuerInspector =
+                (appInfo, enqueuerMode) -> {
+                  throw new RuntimeException();
+                });
+  }
+}
diff --git a/third_party/closedsource-apps/systemui.tar.gz.sha1 b/third_party/closedsource-apps/systemui.tar.gz.sha1
new file mode 100644
index 0000000..3c540b5
--- /dev/null
+++ b/third_party/closedsource-apps/systemui.tar.gz.sha1
@@ -0,0 +1 @@
+f76d84da88b3466adb11039cf9472f39b6ba64cc
\ No newline at end of file
diff --git a/tools/perf.py b/tools/perf.py
index 9cdc597..9baa17a 100755
--- a/tools/perf.py
+++ b/tools/perf.py
@@ -82,10 +82,12 @@
 }
 # A collection of extra benchmarks that should not be run on the bots, but can
 # be used for running locally.
-LOCAL_BENCHMARKS = {}
+EXTRA_BENCHMARKS = {
+    'SystemUIApp': {'targets': ['r8-full']},
+    'SystemUIAppTreeShaking': {'targets': ['r8-full']}}
 ALL_BENCHMARKS = {}
 ALL_BENCHMARKS.update(BENCHMARKS)
-ALL_BENCHMARKS.update(LOCAL_BENCHMARKS)
+ALL_BENCHMARKS.update(EXTRA_BENCHMARKS)
 BUCKET = "r8-perf-results"
 SAMPLE_BENCHMARK_RESULT_JSON = {
     'benchmark_name': '<benchmark_name>',