-
Notifications
You must be signed in to change notification settings - Fork 674
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support baseline profile generation for coil-base. (#1572)
* Create setupTestModule for the benchmarking module. * Move Proguard files. * Clean up. * Update package. * Fix compilation. * Pass project name through. * Update filtering. * Suppress. * Clean up scripts. * Update publish script. * Use pixel 6.
- Loading branch information
1 parent
ab9813d
commit 872c217
Showing
27 changed files
with
173 additions
and
223 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
./gradlew :coil-benchmark:pixel6Api31BenchmarkAndroidTest -P android.testInstrumentationRunnerArguments.class=coil.benchmark.BaselineProfileGenerator#generate -Dproject=view | ||
mv coil-benchmark/build/outputs/managed_device_android_test_additional_output/pixel6Api31/BaselineProfileGenerator_generate-baseline-prof.txt coil-base/src/main/baseline-prof.txt | ||
./gradlew :coil-benchmark:pixel6Api31BenchmarkAndroidTest -P android.testInstrumentationRunnerArguments.class=coil.benchmark.BaselineProfileGenerator#generate -Dproject=compose | ||
mv coil-benchmark/build/outputs/managed_device_android_test_additional_output/pixel6Api31/BaselineProfileGenerator_generate-baseline-prof.txt coil-compose-base/src/main/baseline-prof.txt |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import coil.setupTestModule | ||
import com.android.build.api.dsl.ManagedVirtualDevice | ||
|
||
plugins { | ||
id("com.android.test") | ||
id("kotlin-android") | ||
} | ||
|
||
setupTestModule(name = "coil.benchmark") { | ||
val targetProject = System.getProperty("project", "view") | ||
defaultConfig { | ||
minSdk = 23 | ||
buildConfigField("String", "PROJECT", "\"$targetProject\"") | ||
} | ||
buildTypes { | ||
create("benchmark") { | ||
isDebuggable = true | ||
signingConfig = getByName("debug").signingConfig | ||
matchingFallbacks += listOf("release") | ||
} | ||
} | ||
testOptions { | ||
managedDevices { | ||
devices { | ||
create<ManagedVirtualDevice>("pixel6Api31") { | ||
device = "Pixel 6" | ||
apiLevel = 31 | ||
systemImageSource = "aosp" | ||
} | ||
} | ||
} | ||
} | ||
targetProjectPath = ":coil-sample-$targetProject" | ||
experimentalProperties["android.experimental.self-instrumenting"] = true | ||
} | ||
|
||
dependencies { | ||
implementation(libs.androidx.benchmark.macro) | ||
implementation(libs.androidx.test.espresso) | ||
implementation(libs.androidx.test.junit) | ||
implementation(libs.androidx.test.uiautomator) | ||
} | ||
|
||
androidComponents { | ||
beforeVariants(selector().all()) { | ||
it.enable = it.buildType == "benchmark" | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...se-benchmark/src/main/AndroidManifest.xml → coil-benchmark/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<queries> | ||
<package android:name="sample.compose" /> | ||
<package android:name="sample.compose"/> | ||
<package android:name="sample.view"/> | ||
</queries> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
coil-benchmark/src/main/java/coil/benchmark/BaselineProfileGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package coil.benchmark | ||
|
||
import androidx.benchmark.macro.junit4.BaselineProfileRule | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation | ||
import androidx.test.uiautomator.By | ||
import androidx.test.uiautomator.Direction | ||
import androidx.test.uiautomator.UiDevice | ||
import coil.benchmark.BuildConfig.PROJECT | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
@Suppress("KotlinConstantConditions") // BuildConfig constant can change. | ||
class BaselineProfileGenerator { | ||
|
||
@get:Rule | ||
val baselineProfileRule = BaselineProfileRule() | ||
|
||
@Test | ||
fun generate() = baselineProfileRule.collectBaselineProfile( | ||
packageName = "sample.$PROJECT", | ||
filterPredicate = newFilterPredicate(), | ||
) { | ||
pressHome() | ||
startActivityAndWait() | ||
UiDevice.getInstance(getInstrumentation()) | ||
.findObject( | ||
if (PROJECT == "compose") { | ||
By.res("list") | ||
} else { | ||
By.res(packageName, "list") | ||
}, | ||
) | ||
.fling(Direction.DOWN, 3000) | ||
device.waitForIdle() | ||
} | ||
|
||
private fun newFilterPredicate(): (String) -> Boolean { | ||
// Only include Compose-specific rules in the coil-compose module. | ||
val packageName = if (PROJECT == "compose") "coil/compose/" else "coil/" | ||
return { line -> packageName in line && "sample/" !in line } | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
coil-compose-benchmark/src/main/java/coil/compose/benchmark/BaselineProfileGenerator.kt
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.