summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Siarhei Vishniakou <svv@google.com> 2025-02-13 16:04:20 -0800
committer Siarhei Vishniakou <svv@google.com> 2025-03-05 18:48:57 -0800
commit2b5fbafd37a066a89b68d90d234a813be672f67b (patch)
treef1dcec095670626e4de918f813c84a9515848107
parent8c9735d34672db10fe20a75f1b173e99a2665dd2 (diff)
Add touch down-move-up benchmark
This will exercise the basic inputflinger pipeline for handling touch events. The purpose is to mainly serve as a template for adding future benchmarks. Also, move existing input-related benchmarks into the InputPerfTests, so that they are all in one place. This allows us to specify custom build rules like treating kotlin warnings as errors, including specific libraries, etc. Example output: com.android.perftests.input (1 Test) [1/1] android.input.TouchPerfTest#testDownMoveUp: PASSED (9.488s) downMoveUp_mean (ns): 81734303 downMoveUp_median (ns): 81343021 downMoveUp_min (ns): 75008516 downMoveUp_standardDeviation: 5514345 Bug: 396219004 Test: atest InputPerfTests Flag: TEST_ONLY Change-Id: I686c0fa6d2d5745ca0d4d69f12308331e37b818f
-rw-r--r--apct-tests/perftests/core/src/android/input/OWNERS3
-rw-r--r--apct-tests/perftests/input/Android.bp44
-rw-r--r--apct-tests/perftests/input/AndroidManifest.xml37
-rw-r--r--apct-tests/perftests/input/OWNERS2
-rw-r--r--apct-tests/perftests/input/src/android/input/InputPerfRunPrecondition.kt22
-rw-r--r--apct-tests/perftests/input/src/android/input/MotionPredictorBenchmark.kt (renamed from apct-tests/perftests/core/src/android/input/MotionPredictorBenchmark.kt)0
-rw-r--r--apct-tests/perftests/input/src/android/input/TouchPerfTest.kt66
-rw-r--r--apct-tests/perftests/input/src/android/input/VelocityTrackerBenchmarkTest.kt (renamed from apct-tests/perftests/core/src/android/input/VelocityTrackerBenchmarkTest.kt)2
8 files changed, 172 insertions, 4 deletions
diff --git a/apct-tests/perftests/core/src/android/input/OWNERS b/apct-tests/perftests/core/src/android/input/OWNERS
deleted file mode 100644
index 95e3f0213f49..000000000000
--- a/apct-tests/perftests/core/src/android/input/OWNERS
+++ /dev/null
@@ -1,3 +0,0 @@
-include platform/frameworks/base:/INPUT_OWNERS
-
-# Bug component: 136048
diff --git a/apct-tests/perftests/input/Android.bp b/apct-tests/perftests/input/Android.bp
new file mode 100644
index 000000000000..21b66cf3245c
--- /dev/null
+++ b/apct-tests/perftests/input/Android.bp
@@ -0,0 +1,44 @@
+// Copyright 2025 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package {
+ default_team: "trendy_team_input_framework",
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "frameworks_base_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["frameworks_base_license"],
+}
+
+android_test {
+ name: "InputPerfTests",
+ srcs: ["src/**/*.kt"],
+ kotlincflags: [
+ "-Werror",
+ ],
+ static_libs: [
+ "androidx.annotation_annotation",
+ "androidx.test.rules",
+ "apct-perftests-utils",
+ "collector-device-lib",
+ "compatibility-device-util-axt",
+ "cts-input-lib",
+ "platform-test-annotations",
+ ],
+ test_suites: ["device-tests"],
+ data: [":perfetto_artifacts"],
+ platform_apis: true,
+ certificate: "platform",
+}
diff --git a/apct-tests/perftests/input/AndroidManifest.xml b/apct-tests/perftests/input/AndroidManifest.xml
new file mode 100644
index 000000000000..e9e4fd071b47
--- /dev/null
+++ b/apct-tests/perftests/input/AndroidManifest.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 2025 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.perftests.input">
+
+ <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
+ <application>
+ <uses-library android:name="android.test.runner" />
+ <activity android:name="com.android.cts.input.CaptureEventActivity"
+ android:label="Capture events"
+ android:configChanges="touchscreen|uiMode|orientation|screenSize|screenLayout|keyboardHidden|uiMode|navigation|keyboard|density|fontScale|layoutDirection|locale|mcc|mnc|smallestScreenSize"
+ android:enableOnBackInvokedCallback="false"
+ android:turnScreenOn="true"
+ android:exported="true">
+ </activity>
+ </application>
+
+ <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.perftests.input">
+ <meta-data android:name="listener" android:value="android.input.InputPerfRunPrecondition" />
+ </instrumentation>
+</manifest>
diff --git a/apct-tests/perftests/input/OWNERS b/apct-tests/perftests/input/OWNERS
new file mode 100644
index 000000000000..3cffce960b1c
--- /dev/null
+++ b/apct-tests/perftests/input/OWNERS
@@ -0,0 +1,2 @@
+# Bug component: 136048
+include /core/java/android/hardware/input/OWNERS
diff --git a/apct-tests/perftests/input/src/android/input/InputPerfRunPrecondition.kt b/apct-tests/perftests/input/src/android/input/InputPerfRunPrecondition.kt
new file mode 100644
index 000000000000..d992380241a4
--- /dev/null
+++ b/apct-tests/perftests/input/src/android/input/InputPerfRunPrecondition.kt
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.input
+
+import android.perftests.utils.WindowPerfRunPreconditionBase
+
+/** Prepare the preconditions before running performance test. */
+class InputPerfRunPrecondition : WindowPerfRunPreconditionBase()
diff --git a/apct-tests/perftests/core/src/android/input/MotionPredictorBenchmark.kt b/apct-tests/perftests/input/src/android/input/MotionPredictorBenchmark.kt
index cf93331d87c2..cf93331d87c2 100644
--- a/apct-tests/perftests/core/src/android/input/MotionPredictorBenchmark.kt
+++ b/apct-tests/perftests/input/src/android/input/MotionPredictorBenchmark.kt
diff --git a/apct-tests/perftests/input/src/android/input/TouchPerfTest.kt b/apct-tests/perftests/input/src/android/input/TouchPerfTest.kt
new file mode 100644
index 000000000000..26f101d91573
--- /dev/null
+++ b/apct-tests/perftests/input/src/android/input/TouchPerfTest.kt
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.input
+
+import android.cts.input.EventVerifier
+import android.perftests.utils.PerfStatusReporter
+import android.view.MotionEvent.ACTION_DOWN
+import android.view.MotionEvent.ACTION_MOVE
+import android.view.MotionEvent.ACTION_UP
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.platform.app.InstrumentationRegistry
+import com.android.cts.input.CaptureEventActivity
+import com.android.cts.input.UinputTouchScreen
+import com.android.cts.input.VirtualDisplayActivityScenario
+import com.android.cts.input.inputeventmatchers.withMotionAction
+import org.junit.Rule
+import org.junit.Test
+import org.junit.rules.TestName
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class TouchPerfTest {
+ @get:Rule val testName = TestName()
+ @get:Rule val perfStatusReporter = PerfStatusReporter()
+ @get:Rule
+ val virtualDisplayRule = VirtualDisplayActivityScenario.Rule<CaptureEventActivity>(testName)
+
+ private val instrumentation = InstrumentationRegistry.getInstrumentation()
+
+ @Test
+ fun testDownMoveUp() {
+ UinputTouchScreen(instrumentation, virtualDisplayRule.virtualDisplay.display).use {
+ touchScreen ->
+ val verifier = EventVerifier(virtualDisplayRule.activity::getInputEvent)
+ val state = perfStatusReporter.benchmarkState
+
+ while (state.keepRunning()) {
+ val x = 100
+ val y = 100
+
+ val pointer = touchScreen.touchDown(x, y)
+ verifier.assertReceivedMotion(withMotionAction(ACTION_DOWN))
+
+ pointer.moveTo(x + 1, y + 1)
+ verifier.assertReceivedMotion(withMotionAction(ACTION_MOVE))
+
+ pointer.lift()
+ verifier.assertReceivedMotion(withMotionAction(ACTION_UP))
+ }
+ }
+ }
+}
diff --git a/apct-tests/perftests/core/src/android/input/VelocityTrackerBenchmarkTest.kt b/apct-tests/perftests/input/src/android/input/VelocityTrackerBenchmarkTest.kt
index c6fe32467099..df58cca42d44 100644
--- a/apct-tests/perftests/core/src/android/input/VelocityTrackerBenchmarkTest.kt
+++ b/apct-tests/perftests/input/src/android/input/VelocityTrackerBenchmarkTest.kt
@@ -19,8 +19,8 @@ import android.perftests.utils.PerfStatusReporter
import android.view.InputDevice
import android.view.MotionEvent
import android.view.VelocityTracker
+import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
-import androidx.test.runner.AndroidJUnit4
import java.time.Duration
import org.junit.Assert
import org.junit.Before