diff options
| author | 2024-12-31 08:35:54 -0800 | |
|---|---|---|
| committer | 2024-12-31 08:35:54 -0800 | |
| commit | ee4d016951799b43d624977f7425c96015f684eb (patch) | |
| tree | d800d6dd12c72fe70a8163761cda6148499b39cf | |
| parent | 083435bc3b4af4d8e91a79fc39e41ed96d7176ba (diff) | |
| parent | 0cfd10b46731a3dd5f2ab8d738311c493bdfdea7 (diff) | |
Merge "add Aconfig perf test" into main am: 214b1afe18 am: 0cfd10b467
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/3428801
Change-Id: I8f822edf7e1d85bcedf43b2aa3d1a385847a4a30
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | apct-tests/perftests/aconfig/Android.bp | 39 | ||||
| -rw-r--r-- | apct-tests/perftests/aconfig/AndroidManifest.xml | 27 | ||||
| -rw-r--r-- | apct-tests/perftests/aconfig/AndroidTest.xml | 63 | ||||
| -rw-r--r-- | apct-tests/perftests/aconfig/OWNERS | 1 | ||||
| -rw-r--r-- | apct-tests/perftests/aconfig/src/android/os/flagging/AconfigPackagePerfTest.java | 139 |
5 files changed, 269 insertions, 0 deletions
diff --git a/apct-tests/perftests/aconfig/Android.bp b/apct-tests/perftests/aconfig/Android.bp new file mode 100644 index 000000000000..715923de1eb7 --- /dev/null +++ b/apct-tests/perftests/aconfig/Android.bp @@ -0,0 +1,39 @@ +// Copyright (C) 2024 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_android_core_experiments", + // 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: "AconfigPerfTests", + srcs: ["src/**/*.java"], + static_libs: [ + "aconfig_device_paths_java_util", + "androidx.test.rules", + "apct-perftests-utils", + "collector-device-lib", + "truth", + ], + platform_apis: true, + certificate: "platform", + test_suites: ["device-tests"], + data: [":perfetto_artifacts"], +} diff --git a/apct-tests/perftests/aconfig/AndroidManifest.xml b/apct-tests/perftests/aconfig/AndroidManifest.xml new file mode 100644 index 000000000000..e9d7c176303f --- /dev/null +++ b/apct-tests/perftests/aconfig/AndroidManifest.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2020 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.aconfig"> + + <application> + <uses-library android:name="android.test.runner" /> + </application> + + <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" + android:targetPackage="com.android.perftests.aconfig"/> + +</manifest>
\ No newline at end of file diff --git a/apct-tests/perftests/aconfig/AndroidTest.xml b/apct-tests/perftests/aconfig/AndroidTest.xml new file mode 100644 index 000000000000..036e0310def2 --- /dev/null +++ b/apct-tests/perftests/aconfig/AndroidTest.xml @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2018 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. +--> +<configuration description="Runs AconfigPerfTests metric instrumentation."> + <option name="test-suite-tag" value="apct" /> + <option name="test-suite-tag" value="apct-metric-instrumentation" /> + + <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller"> + <option name="cleanup-apks" value="true" /> + <option name="test-file-name" value="AconfigPerfTests.apk" /> + </target_preparer> + + <!-- Needed for pushing the trace config file --> + <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/> + <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer"> + <option name="push-file" key="trace_config_detailed.textproto" value="/data/misc/perfetto-traces/trace_config.textproto" /> + </target_preparer> + + + <!-- Needed for pulling the collected trace config on to the host --> + <metrics_collector class="com.android.tradefed.device.metric.FilePullerLogCollector"> + <option name="pull-pattern-keys" value="perfetto_file_path" /> + </metrics_collector> + + <!-- Needed for storing the perfetto trace files in the sdcard/test_results--> + <option name="isolated-storage" value="false" /> + + <test class="com.android.tradefed.testtype.AndroidJUnitTest" > + <option name="package" value="com.android.perftests.aconfig" /> + <option name="hidden-api-checks" value="false"/> + + <!-- Listener related args for collecting the traces and waiting for the device to stabilize. --> + <option name="device-listeners" value="android.device.collectors.ProcLoadListener,android.device.collectors.PerfettoListener" /> + <!-- Guarantee that user defined RunListeners will be running before any of the default listeners defined in this runner. --> + <option name="instrumentation-arg" key="newRunListenerMode" value="true" /> + + <!-- ProcLoadListener related arguments --> + <!-- Wait for device last minute threshold to reach 3 with 2 minute timeout before starting the test run --> + <option name="instrumentation-arg" key="procload-collector:per_run" value="true" /> + <option name="instrumentation-arg" key="proc-loadavg-threshold" value="3" /> + <option name="instrumentation-arg" key="proc-loadavg-timeout" value="120000" /> + <option name="instrumentation-arg" key="proc-loadavg-interval" value="10000" /> + + <!-- PerfettoListener related arguments --> + <option name="instrumentation-arg" key="perfetto_config_text_proto" value="true" /> + <option name="instrumentation-arg" key="perfetto_config_file" value="trace_config.textproto" /> + + <option name="instrumentation-arg" key="newRunListenerMode" value="true" /> + + </test> +</configuration>
\ No newline at end of file diff --git a/apct-tests/perftests/aconfig/OWNERS b/apct-tests/perftests/aconfig/OWNERS new file mode 100644 index 000000000000..2202076593fb --- /dev/null +++ b/apct-tests/perftests/aconfig/OWNERS @@ -0,0 +1 @@ +file:platform/packages/modules/ConfigInfrastructure:/OWNERS
\ No newline at end of file diff --git a/apct-tests/perftests/aconfig/src/android/os/flagging/AconfigPackagePerfTest.java b/apct-tests/perftests/aconfig/src/android/os/flagging/AconfigPackagePerfTest.java new file mode 100644 index 000000000000..df6e3c836256 --- /dev/null +++ b/apct-tests/perftests/aconfig/src/android/os/flagging/AconfigPackagePerfTest.java @@ -0,0 +1,139 @@ +/* + * Copyright 2024 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.os.flagging; + +import static com.google.common.truth.Truth.assertThat; + +import android.aconfig.DeviceProtosTestUtil; +import android.aconfig.nano.Aconfig.parsed_flag; +import android.perftests.utils.BenchmarkState; +import android.perftests.utils.PerfStatusReporter; + +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +@RunWith(Parameterized.class) +public class AconfigPackagePerfTest { + + @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + + @Parameterized.Parameters(name = "isPlatform={0}") + public static Collection<Object[]> data() { + return Arrays.asList(new Object[][] {{false}, {true}}); + } + + private static final Set<String> PLATFORM_CONTAINERS = Set.of("system", "vendor", "product"); + private static List<parsed_flag> sFlags; + + @BeforeClass + public static void init() { + try { + sFlags = DeviceProtosTestUtil.loadAndParseFlagProtos(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Parameterized.Parameter(0) + + // if this variable is true, then the test query flags from system/product/vendor + // if this variable is false, then the test query flags from updatable partitions + public boolean mIsPlatform; + + @Test + public void timeAconfigPackageLoadOnePackage() { + String packageName = ""; + for (parsed_flag flag : sFlags) { + if (mIsPlatform == PLATFORM_CONTAINERS.contains(flag.container)) { + packageName = flag.package_; + break; + } + } + BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + AconfigPackage.load(packageName); + } + } + + @Test + public void timeAconfigPackageLoadMultiplePackages() { + // load num packages + int packageNum = 25; + Set<String> packageSet = new HashSet<>(); + for (parsed_flag flag : sFlags) { + if (mIsPlatform == PLATFORM_CONTAINERS.contains(flag.container)) { + packageSet.add(flag.package_); + } + if (packageSet.size() >= packageNum) { + break; + } + } + List<String> packageList = new ArrayList(packageSet); + assertThat(packageList.size()).isAtLeast(packageNum); + BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + for (int i = 0; state.keepRunning(); i++) { + AconfigPackage.load(packageList.get(i % packageNum)); + } + } + + @Test + public void timeAconfigPackageGetBooleanFlagValue() { + // get one package contains num of flags + int flagNum = 20; + List<parsed_flag> l = findNumFlagsInSamePackage(flagNum, mIsPlatform); + List<String> flagName = new ArrayList<>(); + String packageName = l.get(0).package_; + for (parsed_flag flag : l) { + flagName.add(flag.name); + } + assertThat(flagName.size()).isAtLeast(flagNum); + BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + AconfigPackage ap = AconfigPackage.load(packageName); + for (int i = 0; state.keepRunning(); i++) { + ap.getBooleanFlagValue(flagName.get(i % flagNum), false); + } + } + + private static List<parsed_flag> findNumFlagsInSamePackage(int num, boolean isPlatform) { + Map<String, List<parsed_flag>> packageToFlag = new HashMap<>(); + List<parsed_flag> ret = new ArrayList<parsed_flag>(); + for (parsed_flag flag : sFlags) { + if (isPlatform == PLATFORM_CONTAINERS.contains(flag.container)) { + ret = + packageToFlag.computeIfAbsent( + flag.package_, k -> new ArrayList<parsed_flag>()); + ret.add(flag); + if (ret.size() >= num) { + break; + } + } + } + return ret; + } +} |