Add a baseline profile for material3
I was worried about regressing other list benchmarks so I added a new
activity for generating baseline profiles and included both m2 and m3
components.
Test: SmallListBaselineProfile
Fixes: 262611060
Change-Id: Ied6f142c2874d7bc596dab43717e5a9ebcc51502
diff --git a/compose/integration-tests/macrobenchmark-target/build.gradle b/compose/integration-tests/macrobenchmark-target/build.gradle
index e1368a6..f521117 100644
--- a/compose/integration-tests/macrobenchmark-target/build.gradle
+++ b/compose/integration-tests/macrobenchmark-target/build.gradle
@@ -34,6 +34,7 @@
implementation(project(":compose:foundation:foundation-layout"))
implementation(project(":compose:foundation:foundation"))
implementation(project(":compose:material:material"))
+ implementation(project(":compose:material3:material3"))
implementation(project(":compose:runtime:runtime"))
implementation(project(":compose:runtime:runtime-tracing"))
implementation(project(":compose:ui:ui"))
diff --git a/compose/integration-tests/macrobenchmark-target/src/main/AndroidManifest.xml b/compose/integration-tests/macrobenchmark-target/src/main/AndroidManifest.xml
index 8d6b34e..0b745aa 100644
--- a/compose/integration-tests/macrobenchmark-target/src/main/AndroidManifest.xml
+++ b/compose/integration-tests/macrobenchmark-target/src/main/AndroidManifest.xml
@@ -72,6 +72,14 @@
</intent-filter>
</activity>
<activity
+ android:name=".BaselineProfileActivity"
+ android:exported="true">
+ <intent-filter>
+ <action android:name="androidx.compose.integration.macrobenchmark.target.BASELINE_PROFILE_ACTIVITY" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+ <activity
android:name=".NestedListsActivity"
android:exported="true">
<intent-filter>
diff --git a/compose/integration-tests/macrobenchmark-target/src/main/java/androidx/compose/integration/macrobenchmark/target/BaselineProfileActivity.kt b/compose/integration-tests/macrobenchmark-target/src/main/java/androidx/compose/integration/macrobenchmark/target/BaselineProfileActivity.kt
new file mode 100644
index 0000000..a94f36b
--- /dev/null
+++ b/compose/integration-tests/macrobenchmark-target/src/main/java/androidx/compose/integration/macrobenchmark/target/BaselineProfileActivity.kt
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.compose.integration.macrobenchmark.target
+
+import android.os.Bundle
+import androidx.activity.ComponentActivity
+import androidx.activity.compose.setContent
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.itemsIndexed
+import androidx.compose.material.Card
+import androidx.compose.material.Checkbox
+import androidx.compose.material.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.semantics.contentDescription
+import androidx.compose.ui.semantics.semantics
+import androidx.compose.ui.unit.dp
+
+class BaselineProfileActivity : ComponentActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+
+ val itemCount = intent.getIntExtra(EXTRA_ITEM_COUNT, 3000)
+ val entries = List(itemCount) { Entry("Item $it") }
+
+ setContent {
+ LazyColumn(
+ modifier = Modifier
+ .fillMaxWidth()
+ .semantics { contentDescription = "IamLazy" }
+ ) {
+ itemsIndexed(entries) { index, item ->
+ if (index % 2 == 0) {
+ M3ListRow(entry = item)
+ } else {
+ ListRow(item)
+ }
+ }
+ }
+ }
+
+ launchIdlenessTracking()
+ }
+
+ companion object {
+ const val EXTRA_ITEM_COUNT = "ITEM_COUNT"
+ }
+}
+
+@Composable
+private fun ListRow(entry: Entry) {
+ Card(modifier = Modifier.padding(8.dp)) {
+ Row {
+ Text(
+ text = entry.contents,
+ modifier = Modifier.padding(16.dp)
+ )
+ Spacer(modifier = Modifier.weight(1f, fill = true))
+ Checkbox(
+ checked = false,
+ onCheckedChange = {},
+ modifier = Modifier.padding(16.dp)
+ )
+ }
+ }
+}
+
+@Composable
+internal fun M3ListRow(entry: Entry) {
+ androidx.compose.material3.Card(modifier = Modifier.padding(8.dp)) {
+ Row {
+ androidx.compose.material3.Text(
+ text = entry.contents,
+ modifier = Modifier.padding(16.dp)
+ )
+ Spacer(modifier = Modifier.weight(1f, fill = true))
+ androidx.compose.material3.Checkbox(
+ checked = false,
+ onCheckedChange = {},
+ modifier = Modifier.padding(16.dp)
+ )
+ }
+ }
+}
\ No newline at end of file
diff --git a/compose/integration-tests/macrobenchmark/src/androidTest/java/androidx/compose/integration/macrobenchmark/SmallListBaselineProfile.kt b/compose/integration-tests/macrobenchmark/src/androidTest/java/androidx/compose/integration/macrobenchmark/SmallListBaselineProfile.kt
index ad73439..b3b12d7 100644
--- a/compose/integration-tests/macrobenchmark/src/androidTest/java/androidx/compose/integration/macrobenchmark/SmallListBaselineProfile.kt
+++ b/compose/integration-tests/macrobenchmark/src/androidTest/java/androidx/compose/integration/macrobenchmark/SmallListBaselineProfile.kt
@@ -42,7 +42,7 @@
intent.apply {
setPackage(packageName)
action =
- "androidx.compose.integration.macrobenchmark.target.LAZY_COLUMN_ACTIVITY"
+ "androidx.compose.integration.macrobenchmark.target.BASELINE_PROFILE_ACTIVITY"
putExtra("ITEM_COUNT", 200)
}
startActivityAndWait(intent)
diff --git a/compose/material3/material3/src/androidMain/baseline-prof.txt b/compose/material3/material3/src/androidMain/baseline-prof.txt
new file mode 100644
index 0000000..6a2e2b7
--- /dev/null
+++ b/compose/material3/material3/src/androidMain/baseline-prof.txt
@@ -0,0 +1,27 @@
+# Baseline profile rules for androidx.compose.material3
+# =============================================
+
+HSPLandroidx/compose/material3/CardColors;->**(**)**
+HSPLandroidx/compose/material3/CardElevation;->**(**)**
+HSPLandroidx/compose/material3/CardKt**->**(**)**
+HSPLandroidx/compose/material3/CheckDrawingCache;->**(**)**
+HSPLandroidx/compose/material3/CheckboxColors;->**(**)**
+HSPLandroidx/compose/material3/CheckboxKt**->**(**)**
+HSPLandroidx/compose/material3/ColorScheme**->**(**)**
+HSPLandroidx/compose/material3/ContentColorKt;->**(**)**
+HSPLandroidx/compose/material3/DefaultPlatformTextStyle_androidKt;->**(**)**
+HSPLandroidx/compose/material3/InteractiveComponentSizeKt;->**(**)**
+HSPLandroidx/compose/material3/MinimumInteractiveComponentSizeModifier**->**(**)**
+HSPLandroidx/compose/material3/ShapeDefaults;->**(**)**
+HSPLandroidx/compose/material3/Shapes;->**(**)**
+HSPLandroidx/compose/material3/ShapesKt**->**(**)**
+HSPLandroidx/compose/material3/SurfaceKt**->**(**)**
+HSPLandroidx/compose/material3/TextKt**->**(**)**
+HSPLandroidx/compose/material3/CheckboxTokens;->**(**)**
+HSPLandroidx/compose/material3/ColorDarkTokens;->**(**)**
+HSPLandroidx/compose/material3/ColorLightTokens;->**(**)**
+HSPLandroidx/compose/material3/ElevationTokens;->**(**)**
+HSPLandroidx/compose/material3/FilledCardTokens;->**(**)**
+HSPLandroidx/compose/material3/PaletteTokens;->**(**)**
+HSPLandroidx/compose/material3/ShapeTokens;->**(**)**
+HSPLandroidx/compose/material3/TypographyTokens;->**(**)**