Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 76457271 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12860712 from cf1202db to 25Q2-release

Change-Id: I132f51f79240d7b8f2daff2a9f70748914c1854f
parents 9279ec65 cf1202db
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
// 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"],
}
+27 −0
Original line number Diff line number Diff line
<?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
+63 −0
Original line number Diff line number Diff line
<?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
+1 −0
Original line number Diff line number Diff line
file:platform/packages/modules/ConfigInfrastructure:/OWNERS
 No newline at end of file
+139 −0
Original line number Diff line number Diff line
/*
 * 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;
    }
}
Loading