Fail when benchmarks throw unexpected exceptions
Change-Id: Ic0644a4b3cd52f5d5e071bcd3f73678f3f17fa4f
diff --git a/src/test/java/com/android/tools/r8/benchmarks/appdumps/AbortBenchmarkException.java b/src/test/java/com/android/tools/r8/benchmarks/appdumps/AbortBenchmarkException.java
new file mode 100644
index 0000000..9c7a048
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/benchmarks/appdumps/AbortBenchmarkException.java
@@ -0,0 +1,6 @@
+// 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;
+
+public class AbortBenchmarkException extends RuntimeException {}
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 2806772..c63ca2c 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 com.android.tools.r8.LibraryDesugaringTestConfiguration;
import com.android.tools.r8.R8FullTestBuilder;
import com.android.tools.r8.TestBase;
@@ -313,7 +312,7 @@
.benchmarkInstructionCodeSize(results)
.benchmarkDexSegmentsCodeSize(results)
.benchmarkDex2OatCodeSize(results);
- } catch (Exception e) {
+ } catch (AbortBenchmarkException e) {
// Ignore.
}
});
diff --git a/src/test/java/com/android/tools/r8/internal/benchmarks/appdumps/SystemUIBenchmarks.java b/src/test/java/com/android/tools/r8/internal/benchmarks/appdumps/SystemUIBenchmarks.java
index 70ec642..045537d 100644
--- a/src/test/java/com/android/tools/r8/internal/benchmarks/appdumps/SystemUIBenchmarks.java
+++ b/src/test/java/com/android/tools/r8/internal/benchmarks/appdumps/SystemUIBenchmarks.java
@@ -8,7 +8,9 @@
import com.android.tools.r8.ToolHelper;
import com.android.tools.r8.benchmarks.BenchmarkBase;
import com.android.tools.r8.benchmarks.BenchmarkConfig;
+import com.android.tools.r8.benchmarks.appdumps.AbortBenchmarkException;
import com.android.tools.r8.benchmarks.appdumps.AppDumpBenchmarkBuilder;
+import com.android.tools.r8.utils.Timing;
import com.google.common.collect.ImmutableList;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -66,7 +68,12 @@
options ->
options.getTestingOptions().enqueuerInspector =
(appInfo, enqueuerMode) -> {
- throw new RuntimeException();
+ if (appInfo.options().printTimes) {
+ Timing timing = appInfo.app().timing;
+ timing.end();
+ timing.report();
+ }
+ throw new AbortBenchmarkException();
});
}