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

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

Snap for 12278291 from 4d06f18f to 24Q4-release

Change-Id: I8d43bde04fa3c2fcc731f4bcf99f194373ba83e9
parents c034a3f9 4d06f18f
Loading
Loading
Loading
Loading
+33 −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.

android_test {
    name: "ProtologPerfTests",
    team: "trendy_team_windowing_tools",
    srcs: ["src/**/*.java"],
    static_libs: [
        "androidx.test.rules",
        "androidx.annotation_annotation",
        "apct-perftests-utils",
        "collector-device-lib",
        "platform-test-annotations",
    ],
    test_suites: [
        "device-tests",
        "automotive-tests",
    ],
    data: [":perfetto_artifacts"],
    platform_apis: true,
    certificate: "platform",
}
+31 −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.protolog">

    <!-- For perfetto trace files -->
    <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" />
    </application>

    <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
        android:targetPackage="com.android.perftests.protolog">
        <!-- <meta-data android:name="listener" android:value="android.protolog.ProtologPerfRunListener" /> -->
    </instrumentation>
</manifest>
+67 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<configuration description="Runs ProtologPerfTests 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="ProtologPerfTests.apk" />
    </target_preparer>

    <target_preparer class="com.android.tradefed.targetprep.DeviceSetup">
        <option name="force-skip-system-props" value="true" />
        <option name="run-command" value="input keyevent KEYCODE_WAKEUP" />
        <option name="run-command" value="cmd window dismiss-keyguard" />
        <option name="run-command" value="cmd package compile -m speed com.android.perftests.wm" />
    </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 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.protolog" />
        <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" />
    </test>

    <!-- <metrics_collector class="com.android.tradefed.device.metric.FilePullerLogCollector">
        <option name="directory-keys" value="/data/local/tmp/ProtologPerfTests" /> -->
        <!-- Needed for pulling the collected trace config on to the host -->
        <!-- <option name="pull-pattern-keys" value="perfetto_file_path" />
    </metrics_collector> -->
</configuration>
+1 −0
Original line number Diff line number Diff line
include platform/development:/tools/winscope/OWNERS
+171 −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 com.android.internal.protolog;

import android.perftests.utils.BenchmarkState;
import android.perftests.utils.PerfStatusReporter;

import com.android.internal.protolog.common.IProtoLogGroup;
import com.android.internal.protolog.common.LogLevel;

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import java.util.Arrays;
import java.util.Collection;

@RunWith(Parameterized.class)
public class ProtologPerfTest {
    @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();

    @Parameters(name="logToProto_{0}_logToLogcat_{1}")
    public static Collection<Object[]> params() {
        return Arrays.asList(new Object[][] {
                { true, true },
                { true, false },
                { false, true },
                { false, false }
        });
    }

    private final boolean mLogToProto;
    private final boolean mLogToLogcat;

    public ProtologPerfTest(boolean logToProto, boolean logToLogcat) {
        mLogToProto = logToProto;
        mLogToLogcat = logToLogcat;
    }

    @BeforeClass
    public static void init() {
        ProtoLog.init(TestProtoLogGroup.values());
    }

    @Before
    public void setUp() {
        TestProtoLogGroup.TEST_GROUP.setLogToProto(mLogToProto);
        TestProtoLogGroup.TEST_GROUP.setLogToLogcat(mLogToLogcat);
    }

    @Test
    public void logProcessedProtoLogMessageWithoutArgs() {
        final var protoLog = ProtoLog.getSingleInstance();

        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            protoLog.log(
                    LogLevel.INFO, TestProtoLogGroup.TEST_GROUP, 123,
                    0, (Object[]) null);
        }
    }

    @Test
    public void logProcessedProtoLogMessageWithArgs() {
        final var protoLog = ProtoLog.getSingleInstance();

        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            protoLog.log(
                    LogLevel.INFO, TestProtoLogGroup.TEST_GROUP, 123,
                    0b1110101001010100,
                    new Object[]{"test", 1, 2, 3, 0.4, 0.5, 0.6, true});
        }
    }

    @Test
    public void logNonProcessedProtoLogMessageWithNoArgs() {
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            ProtoLog.d(TestProtoLogGroup.TEST_GROUP, "Test message");
        }
    }

    @Test
    public void logNonProcessedProtoLogMessageWithArgs() {
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            ProtoLog.d(TestProtoLogGroup.TEST_GROUP, "Test messag %s, %d, %b", "arg1", 2, true);
        }
    }

    private enum TestProtoLogGroup implements IProtoLogGroup {
        TEST_GROUP(true, true, false, "WindowManagetProtoLogTest");

        private final boolean mEnabled;
        private volatile boolean mLogToProto;
        private volatile boolean mLogToLogcat;
        private final String mTag;

        /**
         * @param enabled set to false to exclude all log statements for this group from
         *     compilation, they will not be available in runtime.
         * @param logToProto enable binary logging for the group
         * @param logToLogcat enable text logging for the group
         * @param tag name of the source of the logged message
         */
        TestProtoLogGroup(boolean enabled, boolean logToProto, boolean logToLogcat, String tag) {
            this.mEnabled = enabled;
            this.mLogToProto = logToProto;
            this.mLogToLogcat = logToLogcat;
            this.mTag = tag;
        }

        @Override
        public boolean isEnabled() {
            return mEnabled;
        }

        @Override
        public boolean isLogToProto() {
            return mLogToProto;
        }

        @Override
        public boolean isLogToLogcat() {
            return mLogToLogcat;
        }

        @Override
        public boolean isLogToAny() {
            return mLogToLogcat || mLogToProto;
        }

        @Override
        public String getTag() {
            return mTag;
        }

        @Override
        public void setLogToProto(boolean logToProto) {
            this.mLogToProto = logToProto;
        }

        @Override
        public void setLogToLogcat(boolean logToLogcat) {
            this.mLogToLogcat = logToLogcat;
        }

        @Override
        public int getId() {
            return ordinal();
        }
    }
}
Loading