diff --git a/apct-tests/perftests/core/Android.bp b/apct-tests/perftests/core/Android.bp
index 984893a256055..03ab5b6f2c8cb 100644
--- a/apct-tests/perftests/core/Android.bp
+++ b/apct-tests/perftests/core/Android.bp
@@ -12,6 +12,8 @@ android_test {
"androidx.appcompat_appcompat",
"androidx.test.rules",
"androidx.annotation_annotation",
+ "androidx.benchmark_benchmark-common",
+ "androidx.benchmark_benchmark-junit4",
"apct-perftests-overlay-apps",
"apct-perftests-resources-manager-apps",
"apct-perftests-utils",
diff --git a/apct-tests/perftests/core/AndroidManifest.xml b/apct-tests/perftests/core/AndroidManifest.xml
index e9f4747b45458..833ae63e11257 100644
--- a/apct-tests/perftests/core/AndroidManifest.xml
+++ b/apct-tests/perftests/core/AndroidManifest.xml
@@ -34,7 +34,7 @@
-
diff --git a/apct-tests/perftests/core/src/android/view/CutoutSpecificationBenchmark.java b/apct-tests/perftests/core/src/android/view/CutoutSpecificationBenchmark.java
index 14282bfbd24e8..abd39f880a26a 100644
--- a/apct-tests/perftests/core/src/android/view/CutoutSpecificationBenchmark.java
+++ b/apct-tests/perftests/core/src/android/view/CutoutSpecificationBenchmark.java
@@ -22,13 +22,13 @@ import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Region;
-import android.perftests.utils.BenchmarkState;
-import android.perftests.utils.PerfStatusReporter;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.PathParser;
+import androidx.benchmark.BenchmarkState;
+import androidx.benchmark.junit4.BenchmarkRule;
import androidx.test.filters.LargeTest;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
@@ -67,7 +67,7 @@ public class CutoutSpecificationBenchmark {
+ "Z\n"
+ "@dp";
@Rule
- public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
+ public BenchmarkRule mBenchmarkRule = new BenchmarkRule();
private Context mContext;
private DisplayMetrics mDisplayMetrics;
@@ -168,7 +168,7 @@ public class CutoutSpecificationBenchmark {
@Test
public void parseByOldMethodForDoubleCutout() {
- final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ final BenchmarkState state = mBenchmarkRule.getState();
while (state.keepRunning()) {
oldMethodParsingSpec(DOUBLE_CUTOUT_SPEC, mDisplayMetrics.widthPixels,
mDisplayMetrics.heightPixels, mDisplayMetrics.density);
@@ -177,7 +177,7 @@ public class CutoutSpecificationBenchmark {
@Test
public void parseByNewMethodForDoubleCutout() {
- final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ final BenchmarkState state = mBenchmarkRule.getState();
while (state.keepRunning()) {
new CutoutSpecification.Parser(mDisplayMetrics.density,
mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels)
@@ -209,7 +209,7 @@ public class CutoutSpecificationBenchmark {
+ "@right\n"
+ "@dp";
- final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ final BenchmarkState state = mBenchmarkRule.getState();
while (state.keepRunning()) {
new CutoutSpecification.Parser(mDisplayMetrics.density,
mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels).parse(spec);
@@ -231,7 +231,7 @@ public class CutoutSpecificationBenchmark {
+ "Z\n"
+ "@dp";
- final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ final BenchmarkState state = mBenchmarkRule.getState();
while (state.keepRunning()) {
new CutoutSpecification.Parser(mDisplayMetrics.density,
mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels).parse(spec);
diff --git a/apct-tests/perftests/core/src/android/view/ViewPerfTest.java b/apct-tests/perftests/core/src/android/view/ViewPerfTest.java
index 72f02c488dbd6..a2aeb313cbdeb 100644
--- a/apct-tests/perftests/core/src/android/view/ViewPerfTest.java
+++ b/apct-tests/perftests/core/src/android/view/ViewPerfTest.java
@@ -19,11 +19,11 @@ package android.view;
import static junit.framework.Assert.assertTrue;
import android.content.Context;
-import android.perftests.utils.BenchmarkState;
-import android.perftests.utils.PerfStatusReporter;
import android.perftests.utils.PerfTestActivity;
import android.widget.FrameLayout;
+import androidx.benchmark.BenchmarkState;
+import androidx.benchmark.junit4.BenchmarkRule;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;
@@ -37,7 +37,7 @@ import org.junit.Test;
@LargeTest
public class ViewPerfTest {
@Rule
- public final PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
+ public final BenchmarkRule mBenchmarkRule = new BenchmarkRule();
@Rule
public final ActivityTestRule mActivityRule =
@@ -52,7 +52,7 @@ public class ViewPerfTest {
@Test
public void testSimpleViewInflate() {
- final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ final BenchmarkState state = mBenchmarkRule.getState();
LayoutInflater inflater = LayoutInflater.from(mContext);
FrameLayout root = new FrameLayout(mContext);
while (state.keepRunning()) {
@@ -62,7 +62,7 @@ public class ViewPerfTest {
@Test
public void testTwelveKeyInflate() {
- final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ final BenchmarkState state = mBenchmarkRule.getState();
LayoutInflater inflater = LayoutInflater.from(mContext);
FrameLayout root = new FrameLayout(mContext);
while (state.keepRunning()) {
@@ -72,7 +72,7 @@ public class ViewPerfTest {
@Test
public void testPerformHapticFeedback() throws Throwable {
- final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ final BenchmarkState state = mBenchmarkRule.getState();
mActivityRule.runOnUiThread(() -> {
state.pauseTiming();
View view = new View(mContext);
diff --git a/apct-tests/perftests/core/src/android/view/ViewShowHidePerfTest.java b/apct-tests/perftests/core/src/android/view/ViewShowHidePerfTest.java
index b0edb117a00b4..a69d3ffa46fa3 100644
--- a/apct-tests/perftests/core/src/android/view/ViewShowHidePerfTest.java
+++ b/apct-tests/perftests/core/src/android/view/ViewShowHidePerfTest.java
@@ -21,14 +21,14 @@ import static org.junit.Assert.assertTrue;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
-import android.perftests.utils.BenchmarkState;
-import android.perftests.utils.PerfStatusReporter;
import android.perftests.utils.PerfTestActivity;
import android.view.View.MeasureSpec;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import androidx.benchmark.BenchmarkState;
+import androidx.benchmark.junit4.BenchmarkRule;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;
@@ -50,7 +50,7 @@ public class ViewShowHidePerfTest {
new ActivityTestRule<>(PerfTestActivity.class);
@Rule
- public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
+ public final BenchmarkRule mBenchmarkRule = new BenchmarkRule();
public Context getContext() {
return InstrumentationRegistry.getInstrumentation().getTargetContext();
@@ -143,7 +143,7 @@ public class ViewShowHidePerfTest {
private void testParentWithChild(TestCallback callback) throws Throwable {
mActivityRule.runOnUiThread(() -> {
- final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ final BenchmarkState state = mBenchmarkRule.getState();
FrameLayout parent = new FrameLayout(getContext());
mActivityRule.getActivity().setContentView(parent);