chore: update baseline profile

This commit is contained in:
Bnyro 2024-03-20 20:01:39 +01:00
parent fc894f5f63
commit baef7619d8
8 changed files with 10547 additions and 9442 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@
/build

2
baselineprofile/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/build

View File

@ -1,5 +1,3 @@
import com.android.build.api.dsl.ManagedVirtualDevice
plugins { plugins {
alias(libs.plugins.androidTest) alias(libs.plugins.androidTest)
alias(libs.plugins.jetbrainsKotlinAndroid) alias(libs.plugins.jetbrainsKotlinAndroid)
@ -16,7 +14,7 @@ android {
} }
kotlinOptions { kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString() jvmTarget = "17"
} }
defaultConfig { defaultConfig {
@ -28,21 +26,12 @@ android {
targetProjectPath = ":app" targetProjectPath = ":app"
testOptions.managedDevices.devices {
create<ManagedVirtualDevice>("pixel6Api34") {
device = "Pixel 6"
apiLevel = 34
systemImageSource = "google"
}
}
} }
// This is the configuration block for the Baseline Profile plugin. // This is the configuration block for the Baseline Profile plugin.
// You can specify to run the generators on a managed devices or connected devices. // You can specify to run the generators on a managed devices or connected devices.
// For connected devices, API 28+ (rooted) or 33+ (not rooted) is required.
baselineProfile { baselineProfile {
managedDevices += "pixel6Api34" useConnectedDevices = true
useConnectedDevices = false
} }
dependencies { dependencies {
@ -51,3 +40,12 @@ dependencies {
implementation(libs.androidx.uiautomator) implementation(libs.androidx.uiautomator)
implementation(libs.androidx.benchmark.macro.junit4) implementation(libs.androidx.benchmark.macro.junit4)
} }
androidComponents {
onVariants { v ->
v.instrumentationRunnerArguments.put(
"targetAppId",
v.testedApks.map { v.artifacts.getBuiltArtifactsLoader().load(it)?.applicationId }
)
}
}

View File

@ -5,6 +5,7 @@ import androidx.benchmark.macro.MacrobenchmarkScope
import androidx.benchmark.macro.junit4.BaselineProfileRule import androidx.benchmark.macro.junit4.BaselineProfileRule
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest import androidx.test.filters.LargeTest
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.By import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until import androidx.test.uiautomator.Until
import org.junit.Rule import org.junit.Rule
@ -43,9 +44,10 @@ class BaselineProfileGenerator {
@Test @Test
fun generate() { fun generate() {
// This example works only with the variant with application id `com.github.libretube`." // The application id for the running build variant is read from the instrumentation arguments.
rule.collect( rule.collect(
packageName = "com.github.libretube", packageName = InstrumentationRegistry.getArguments().getString("targetAppId")
?: throw Exception("targetAppId not passed as instrumentation runner arg"),
// See: https://d.android.com/topic/performance/baselineprofiles/dex-layout-optimizations // See: https://d.android.com/topic/performance/baselineprofiles/dex-layout-optimizations
includeInStartupProfile = true includeInStartupProfile = true
@ -75,4 +77,4 @@ class BaselineProfileGenerator {
// Wait until the home page is loaded // Wait until the home page is loaded
device.wait(Until.hasObject(By.text("Home")), 1000) device.wait(Until.hasObject(By.text("Home")), 1000)
} }
} }

View File

@ -7,6 +7,7 @@ import androidx.benchmark.macro.StartupTimingMetric
import androidx.benchmark.macro.junit4.MacrobenchmarkRule import androidx.benchmark.macro.junit4.MacrobenchmarkRule
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest import androidx.test.filters.LargeTest
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
@ -47,9 +48,10 @@ class StartupBenchmarks {
benchmark(CompilationMode.Partial(BaselineProfileMode.Require)) benchmark(CompilationMode.Partial(BaselineProfileMode.Require))
private fun benchmark(compilationMode: CompilationMode) { private fun benchmark(compilationMode: CompilationMode) {
// This example works only with the variant with application id `com.github.libretube`." // The application id for the running build variant is read from the instrumentation arguments.
rule.measureRepeated( rule.measureRepeated(
packageName = "com.github.libretube", packageName = InstrumentationRegistry.getArguments().getString("targetAppId")
?: throw Exception("targetAppId not passed as instrumentation runner arg"),
metrics = listOf(StartupTimingMetric()), metrics = listOf(StartupTimingMetric()),
compilationMode = compilationMode, compilationMode = compilationMode,
startupMode = StartupMode.COLD, startupMode = StartupMode.COLD,
@ -71,4 +73,4 @@ class StartupBenchmarks {
} }
) )
} }
} }