Skip to content

Commit 7980c1d

Browse files
keyboardsurfermlykotomJaehwa-Noh
authored
Configure baseline profiles in the baselineProfile lambda (#1060)
* Configure baseline profiles in the baselineProfile lambda * This is the correct and easiest way to set up baseline profiles correctly. * See b/313428246 for more context. * Handle empty topics during baseline profile generation * Revert to API 33 GMD and fail empty screen tests * Rename withChildren to noChildren for better legibility * Remove unused log tags * Update benchmark and metrics versions * 🤖 Updates baselines for Dependency Guard --------- Co-authored-by: Tomáš Mlynarič <[email protected]> Co-authored-by: Jaehwa Noh <[email protected]>
1 parent 0ba430e commit 7980c1d

File tree

8 files changed

+33
-12
lines changed

8 files changed

+33
-12
lines changed

app-nia-catalog/dependencies/releaseRuntimeClasspath.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0
6868
androidx.lifecycle:lifecycle-viewmodel-savedstate:2.7.0
6969
androidx.lifecycle:lifecycle-viewmodel:2.7.0
7070
androidx.loader:loader:1.0.0
71-
androidx.metrics:metrics-performance:1.0.0-alpha04
71+
androidx.metrics:metrics-performance:1.0.0-beta01
7272
androidx.profileinstaller:profileinstaller:1.3.1
7373
androidx.savedstate:savedstate-ktx:1.2.1
7474
androidx.savedstate:savedstate:1.2.1

app/build.gradle.kts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ android {
5252
// To publish on the Play store a private signing key is required, but to allow anyone
5353
// who clones the code to sign and run the release variant, use the debug signing key.
5454
// TODO: Abstract the signing configuration to a separate file to avoid hardcoding this.
55-
signingConfig = signingConfigs.named("debug").get()
56-
// Ensure Baseline Profile is fresh for release builds.
57-
baselineProfile.automaticGenerationDuringBuild = true
55+
signingConfig = signingConfigs.getByName("debug")
5856
}
5957
}
6058

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

72+
baselineProfile {
73+
saveInSrc = false
74+
// Don't build on every iteration of a full assemble.
75+
// Instead enable generation directly for the release build variant.
76+
automaticGenerationDuringBuild = false
77+
mergeIntoMain = true
78+
variants {
79+
create("release") {
80+
// Ensure Baseline Profile is fresh for release builds.
81+
automaticGenerationDuringBuild = true
82+
}
83+
}
84+
}
85+
7486
dependencies {
7587
implementation(projects.feature.interests)
7688
implementation(projects.feature.foryou)

app/dependencies/prodReleaseRuntimeClasspath.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ androidx.lifecycle:lifecycle-viewmodel-savedstate:2.8.0-alpha04
102102
androidx.lifecycle:lifecycle-viewmodel:2.8.0-alpha04
103103
androidx.loader:loader:1.0.0
104104
androidx.localbroadcastmanager:localbroadcastmanager:1.0.0
105-
androidx.metrics:metrics-performance:1.0.0-alpha04
105+
androidx.metrics:metrics-performance:1.0.0-beta01
106106
androidx.navigation:navigation-common-ktx:2.7.4
107107
androidx.navigation:navigation-common:2.7.4
108108
androidx.navigation:navigation-compose:2.7.4
1.66 KB
Loading

benchmarks/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
import com.android.build.api.dsl.ManagedVirtualDevice
1617
import com.google.samples.apps.nowinandroid.configureFlavors
1718

1819
plugins {
@@ -46,7 +47,7 @@ android {
4647
}
4748

4849
testOptions.managedDevices.devices {
49-
create<com.android.build.api.dsl.ManagedVirtualDevice>("pixel6Api33") {
50+
create<ManagedVirtualDevice>("pixel6Api33") {
5051
device = "Pixel 6"
5152
apiLevel = 33
5253
systemImageSource = "aosp"

benchmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/foryou/ForYouActions.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ fun MacrobenchmarkScope.forYouWaitForContent() {
4141
*/
4242
fun MacrobenchmarkScope.forYouSelectTopics(recheckTopicsIfChecked: Boolean = false) {
4343
val topics = device.findObject(By.res("forYou:topicSelection"))
44+
val noChildren = topics.childCount == 0
45+
if (noChildren) {
46+
// TODO: Ensure ForYou has topics.
47+
fail("No topics found, can't scroll for baseline profile generation.")
48+
}
4449

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

5358
while (visited < 3) {
54-
if (topics.childCount == 0) {
55-
fail("No topics found, can't generate profile for ForYou page.")
56-
}
5759
// Selecting some topics, which will populate items in the feed.
5860
val topic = topics.children[index % topics.childCount]
5961
// Find the checkable element to figure out whether it's checked or not

benchmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/interests/InterestsActions.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import androidx.test.uiautomator.By
2121
import androidx.test.uiautomator.Until
2222
import com.google.samples.apps.nowinandroid.flingElementDownUp
2323
import com.google.samples.apps.nowinandroid.waitForObjectOnTopAppBar
24+
import org.junit.Assert.fail
2425

2526
fun MacrobenchmarkScope.goToInterestsScreen() {
2627
device.findObject(By.text("Interests")).click()
@@ -35,7 +36,12 @@ fun MacrobenchmarkScope.goToInterestsScreen() {
3536
fun MacrobenchmarkScope.interestsScrollTopicsDownUp() {
3637
device.wait(Until.hasObject(By.res("interests:topics")), 5_000)
3738
val topicsList = device.findObject(By.res("interests:topics"))
38-
device.flingElementDownUp(topicsList)
39+
if (topicsList != null) {
40+
// TODO: Ensure topics are availble.
41+
device.flingElementDownUp(topicsList)
42+
} else {
43+
fail("No topics found, can't scroll during baseline profile generation.")
44+
}
3945
}
4046

4147
fun MacrobenchmarkScope.interestsWaitForTopics() {

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ androidxDataStore = "1.0.0"
1818
androidxEspresso = "3.5.1"
1919
androidxHiltNavigationCompose = "1.2.0"
2020
androidxLifecycle = "2.7.0"
21-
androidxMacroBenchmark = "1.2.2"
22-
androidxMetrics = "1.0.0-alpha04"
21+
androidxMacroBenchmark = "1.2.4"
22+
androidxMetrics = "1.0.0-beta01"
2323
androidxNavigation = "2.7.4"
2424
androidxProfileinstaller = "1.3.1"
2525
androidxTestCore = "1.5.0"

0 commit comments

Comments
 (0)