1 /* 2 * Copyright 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.privacysandbox.sdkruntime.integration.macrobenchmark 18 19 import androidx.benchmark.macro.CompilationMode 20 import androidx.benchmark.macro.StartupMode 21 import androidx.benchmark.macro.junit4.MacrobenchmarkRule 22 import androidx.test.filters.LargeTest 23 import androidx.test.platform.app.InstrumentationRegistry 24 import androidx.testutils.measureStartup 25 import org.junit.Rule 26 import org.junit.Test 27 import org.junit.runner.RunWith 28 import org.junit.runners.Parameterized 29 30 /** 31 * ./gradlew :privacysandbox:sdkruntime:integration-tests:macrobenchmark:connectedReleaseAndroidTest 32 */ 33 @LargeTest 34 @RunWith(Parameterized::class) 35 class SdkRuntimeBenchmark( 36 @Suppress("unused") private val ciTestConfigType: String, // Added to test name by Parameterized 37 ) { 38 @get:Rule val benchmarkRule = MacrobenchmarkRule() 39 40 @Test startupnull41 fun startup() = 42 benchmarkRule.measureStartup( 43 compilationMode = CompilationMode.DEFAULT, 44 startupMode = StartupMode.COLD, 45 packageName = "androidx.privacysandbox.sdkruntime.integration.testapp" 46 ) { 47 action = "androidx.privacysandbox.sdkruntime.integration.testapp.BenchmarkActivity" 48 } 49 50 companion object { 51 /** Add test config type (main or compat) to test name */ 52 @Parameterized.Parameters(name = "{0}") 53 @JvmStatic paramsnull54 fun params(): List<String> = 55 listOf( 56 InstrumentationRegistry.getArguments() 57 .getString("androidx.testConfigType", "LOCAL_RUN") 58 ) 59 } 60 } 61