Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure baseline profiles in the baselineProfile lambda V2 #1402

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app-nia-catalog/dependencies/releaseRuntimeClasspath.txt
Expand Up @@ -68,7 +68,7 @@ androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0
androidx.lifecycle:lifecycle-viewmodel-savedstate:2.7.0
androidx.lifecycle:lifecycle-viewmodel:2.7.0
androidx.loader:loader:1.0.0
androidx.metrics:metrics-performance:1.0.0-alpha04
androidx.metrics:metrics-performance:1.0.0-beta01
androidx.profileinstaller:profileinstaller:1.3.1
androidx.savedstate:savedstate-ktx:1.2.1
androidx.savedstate:savedstate:1.2.1
Expand Down
18 changes: 15 additions & 3 deletions app/build.gradle.kts
Expand Up @@ -52,9 +52,7 @@ android {
// To publish on the Play store a private signing key is required, but to allow anyone
// who clones the code to sign and run the release variant, use the debug signing key.
// TODO: Abstract the signing configuration to a separate file to avoid hardcoding this.
signingConfig = signingConfigs.named("debug").get()
// Ensure Baseline Profile is fresh for release builds.
baselineProfile.automaticGenerationDuringBuild = true
signingConfig = signingConfigs.getByName("debug")
}
}

Expand All @@ -71,6 +69,20 @@ android {
namespace = "com.google.samples.apps.nowinandroid"
}

baselineProfile {
saveInSrc = false
// Don't build on every iteration of a full assemble.
// Instead enable generation directly for the release build variant.
automaticGenerationDuringBuild = false
mergeIntoMain = true
variants {
create("release") {
// Ensure Baseline Profile is fresh for release builds.
automaticGenerationDuringBuild = true
}
}
}

dependencies {
implementation(projects.feature.interests)
implementation(projects.feature.foryou)
Expand Down
2 changes: 1 addition & 1 deletion app/dependencies/prodReleaseRuntimeClasspath.txt
Expand Up @@ -102,7 +102,7 @@ androidx.lifecycle:lifecycle-viewmodel-savedstate:2.8.0-alpha04
androidx.lifecycle:lifecycle-viewmodel:2.8.0-alpha04
androidx.loader:loader:1.0.0
androidx.localbroadcastmanager:localbroadcastmanager:1.0.0
androidx.metrics:metrics-performance:1.0.0-alpha04
androidx.metrics:metrics-performance:1.0.0-beta01
androidx.navigation:navigation-common-ktx:2.7.4
androidx.navigation:navigation-common:2.7.4
androidx.navigation:navigation-compose:2.7.4
Expand Down
3 changes: 2 additions & 1 deletion benchmarks/build.gradle.kts
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.android.build.api.dsl.ManagedVirtualDevice
import com.google.samples.apps.nowinandroid.configureFlavors

plugins {
Expand Down Expand Up @@ -46,7 +47,7 @@ android {
}

testOptions.managedDevices.devices {
create<com.android.build.api.dsl.ManagedVirtualDevice>("pixel6Api33") {
create<ManagedVirtualDevice>("pixel6Api33") {
device = "Pixel 6"
apiLevel = 33
systemImageSource = "aosp"
Expand Down
Expand Up @@ -41,6 +41,11 @@ fun MacrobenchmarkScope.forYouWaitForContent() {
*/
fun MacrobenchmarkScope.forYouSelectTopics(recheckTopicsIfChecked: Boolean = false) {
val topics = device.findObject(By.res("forYou:topicSelection"))
val noChildren = topics.childCount == 0
if (noChildren) {
// TODO: Ensure ForYou has topics.
fail("No topics found, can't scroll for baseline profile generation.")
}

// Set gesture margin from sides not to trigger system gesture navigation
val horizontalMargin = 10 * topics.visibleBounds.width() / 100
Expand All @@ -51,9 +56,6 @@ fun MacrobenchmarkScope.forYouSelectTopics(recheckTopicsIfChecked: Boolean = fal
var visited = 0

while (visited < 3) {
if (topics.childCount == 0) {
fail("No topics found, can't generate profile for ForYou page.")
}
// Selecting some topics, which will populate items in the feed.
val topic = topics.children[index % topics.childCount]
// Find the checkable element to figure out whether it's checked or not
Expand Down
Expand Up @@ -21,6 +21,7 @@ import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until
import com.google.samples.apps.nowinandroid.flingElementDownUp
import com.google.samples.apps.nowinandroid.waitForObjectOnTopAppBar
import org.junit.Assert.fail

fun MacrobenchmarkScope.goToInterestsScreen() {
device.findObject(By.text("Interests")).click()
Expand All @@ -35,7 +36,12 @@ fun MacrobenchmarkScope.goToInterestsScreen() {
fun MacrobenchmarkScope.interestsScrollTopicsDownUp() {
device.wait(Until.hasObject(By.res("interests:topics")), 5_000)
val topicsList = device.findObject(By.res("interests:topics"))
device.flingElementDownUp(topicsList)
if (topicsList != null) {
// TODO: Ensure topics are availble.
device.flingElementDownUp(topicsList)
} else {
fail("No topics found, can't scroll during baseline profile generation.")
}
}

fun MacrobenchmarkScope.interestsWaitForTopics() {
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Expand Up @@ -2,7 +2,7 @@
accompanist = "0.34.0"
androidDesugarJdkLibs = "2.0.4"
# AGP and tools should be updated together
androidGradlePlugin = "8.3.0"
androidGradlePlugin = "8.4.0-rc02"
androidTools = "31.3.0"
androidxActivity = "1.8.0"
androidxAppCompat = "1.6.1"
Expand All @@ -18,8 +18,8 @@ androidxDataStore = "1.0.0"
androidxEspresso = "3.5.1"
androidxHiltNavigationCompose = "1.2.0"
androidxLifecycle = "2.7.0"
androidxMacroBenchmark = "1.2.2"
androidxMetrics = "1.0.0-alpha04"
androidxMacroBenchmark = "1.2.4"
androidxMetrics = "1.0.0-beta01"
androidxNavigation = "2.7.4"
androidxProfileinstaller = "1.3.1"
androidxTestCore = "1.5.0"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down