Skip to content

Commit

Permalink
Merge pull request #175 from chikoski/main
Browse files Browse the repository at this point in the history
Migration to Baseline Profile Gradle Plugin
  • Loading branch information
chikoski authored Jun 10, 2024
2 parents dba6602 + 3ffd909 commit 00af306
Show file tree
Hide file tree
Showing 7 changed files with 26,084 additions and 21,432 deletions.
5 changes: 1 addition & 4 deletions JetStreamCompose/baseline-profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

## Generating baseline profiles


To generate the baseline profile for Jetstream app, select the `benchmark` build variant and run the
`BaselineProfileGenerator` benchmark test on your Android TV device.
Then copy the resulting baseline profile to [`jetstream/src/main/baseline-prof.txt`](jetstream/src/main/baseline-prof.txt).
To generate the baseline profile for Jetstream app, run "Generate Baseline Profile" from "**Run**".

> Note: The baseline profile needs to be re-generated for release builds that touch code which changes app startup.
Expand Down
53 changes: 34 additions & 19 deletions JetStreamCompose/benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.android.build.api.dsl.ManagedVirtualDevice

/*
* Copyright 2023 Google LLC
*
Expand All @@ -14,57 +16,70 @@
* limitations under the License.
*/

@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
alias(libs.plugins.android.test)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.androidx.baselineprofile)
}

kotlin {
jvmToolchain(17)
}

composeCompiler {
enableStrongSkippingMode = true
}

android {
namespace = "com.google.jetstream.benchmark"
compileSdk = 34

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = "17"
}

defaultConfig {
minSdk = 28
targetSdk = 34

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments["androidx.benchmark.suppressErrors"] = "EMULATOR"
}

buildFeatures {
compose = true
buildConfig = true
}

buildTypes {
// This benchmark buildType is used for benchmarking, and should function like your
// release build (for example, with minification on). It's signed with a debug key
// for easy local/CI testing.
create("benchmark") {
isDebuggable = true
signingConfig = signingConfigs.getByName("debug")
matchingFallbacks += listOf("release")
testOptions.managedDevices.devices {
create<ManagedVirtualDevice>("tvApi34") {
device = "Television (1080p)"
apiLevel = 34
systemImageSource = "aosp"
}
}

targetProjectPath = ":jetstream"
}

baselineProfile {
managedDevices += "tvApi34"
useConnectedDevices = false
}


dependencies {
implementation(libs.androidx.compose.runtime.base)

implementation(libs.androidx.junit)
implementation(libs.androidx.uiautomator)

// Support for TV activities with LEANBACK_LAUNCHER intent was added in 1.2.0-alpha03 release
// Use 1.2.0-alpha03 or above versions for benchmarking TV apps
implementation(libs.androidx.benchmark.macro.junit4)
implementation(libs.androidx.rules)
}

androidComponents {
beforeVariants(selector().withBuildType("benchmark").all()) {
it.enable = true
}
}
}
24 changes: 15 additions & 9 deletions JetStreamCompose/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
[versions]
activity-compose = "1.9.0"
android-gradle-plugin = "8.4.0"
android-test-plugin = "8.4.0"
android-gradle-plugin = "8.4.1"
android-test-plugin = "8.4.1"
androidx-baselineprofile = "1.2.4"
benchmark-macro-junit4 = "1.2.4"
coil-compose = "2.6.0"
compose-bom = "2024.05.00"
compose-foundation = "1.7.0-beta01"
compose-ui = "1.7.0-beta01"
compose-foundation = "1.7.0-beta02"
compose-ui = "1.7.0-beta02"
compose-runtime = "1.7.0-beta02"
tv-material = "1.0.0-beta01"
core-ktx = "1.13.1"
core-splashscreen = "1.0.1"
hilt-navigation-compose = "1.2.0"
hilt-android = "2.51.1"
junit = "1.1.5"
kotlin-android = "2.0.0-RC3"
kotlin-android = "2.0.0"
kotlinx-serialization = "1.6.0"
ksp = "2.0.0-RC3-1.0.20"
lifecycle-runtime-ktx = "2.8.0"
ksp = "2.0.0-1.0.21"
lifecycle-runtime-ktx = "2.8.1"
media3-ui = "1.3.1"
media3-exoplayer = "1.3.1"
navigation-compose = "2.7.7"
profileinstaller = "1.3.1"
uiautomator = "2.3.0"
rules = "1.5.0"

[libraries]
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activity-compose" }
androidx-benchmark-macro-junit4 = { module = "androidx.benchmark:benchmark-macro-junit4", version.ref = "benchmark-macro-junit4" }
androidx-compose-bom = { module = "androidx.compose:compose-bom", version.ref = "compose-bom" }
androidx-compose-foundation-base = { module = "androidx.compose.foundation:foundation", version.ref = "compose-foundation"}
androidx-compose-foundation-base = { module = "androidx.compose.foundation:foundation", version.ref = "compose-foundation" }
androidx-compose-runtime-base = { module = "androidx.compose.runtime:runtime", version.ref = "compose-runtime" }
androidx-compose-ui-base = { module = "androidx.compose.ui:ui", version.ref = "compose-ui" }
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose-ui" }
androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose-ui" }
Expand All @@ -49,12 +53,14 @@ coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil-compose
hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt-android" }
hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hilt-android" }
kotlinx-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
androidx-rules = { group = "androidx.test", name = "rules", version.ref = "rules" }

[plugins]
android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" }
android-test = { id = "com.android.test", version.ref = "android-test-plugin" }
androidx-baselineprofile = { id = "androidx.baselineprofile", version.ref = "androidx-baselineprofile" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin-android" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin-android" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin-android" }
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt-android" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
16 changes: 5 additions & 11 deletions JetStreamCompose/jetstream/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ plugins {
alias(libs.plugins.compose.compiler)
alias(libs.plugins.hilt)
alias(libs.plugins.ksp)
alias(libs.plugins.androidx.baselineprofile)
}

kotlin {
Expand Down Expand Up @@ -52,23 +53,13 @@ android {

buildTypes {
getByName("release") {
isMinifyEnabled = false
isMinifyEnabled = true
signingConfig = signingConfigs.getByName("debug")
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
create("benchmark") {
initWith(getByName("release"))
signingConfig = signingConfigs.getByName("debug")
matchingFallbacks += listOf("release")
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-benchmark-rules.pro"
)
isDebuggable = false
}
}
buildFeatures {
compose = true
Expand Down Expand Up @@ -131,4 +122,7 @@ dependencies {

// Compose Previews
debugImplementation(libs.androidx.compose.ui.tooling)

// For baseline profile generation
baselineProfile(project(":benchmark"))
}
Loading

0 comments on commit 00af306

Please sign in to comment.