benchmark: init
This commit is contained in:
parent
d8d43a4c88
commit
a66a915e16
|
@ -17,6 +17,20 @@ android {
|
|||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
create("benchmark") {
|
||||
signingConfig = signingConfigs.getByName("debug")
|
||||
matchingFallbacks += listOf("release")
|
||||
isDebuggable = false
|
||||
setProguardFiles(
|
||||
listOf(
|
||||
"proguard-android-optimize.pro",
|
||||
"proguard-rules.pro",
|
||||
"proguard-rules-missing-classes.pro",
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
android:roundIcon="@mipmap/ic_launcher"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Claw.SplashScreen">
|
||||
<profileable
|
||||
android:shell="true"
|
||||
tools:targetApi="29" />
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:configChanges="colorMode|density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
/build
|
|
@ -0,0 +1,62 @@
|
|||
@file:Suppress("DSL_SCOPE_VIOLATION")
|
||||
|
||||
import com.android.build.api.dsl.ManagedVirtualDevice
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.test)
|
||||
id("dev.msfjarvis.claw.android-common")
|
||||
id("dev.msfjarvis.claw.kotlin-android")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "dev.msfjarvis.claw.benchmark"
|
||||
|
||||
defaultConfig { testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" }
|
||||
|
||||
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 = getByName("debug").signingConfig
|
||||
matchingFallbacks += listOf("release")
|
||||
setProguardFiles(
|
||||
listOf(
|
||||
"proguard-android-optimize.pro",
|
||||
"proguard-rules.pro",
|
||||
"proguard-rules-missing-classes.pro",
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
targetProjectPath = ":android"
|
||||
experimentalProperties["android.experimental.self-instrumenting"] = true
|
||||
|
||||
testOptions {
|
||||
managedDevices {
|
||||
devices {
|
||||
register<ManagedVirtualDevice>("pixel2api30") {
|
||||
device = "Pixel 2"
|
||||
apiLevel = 30
|
||||
systemImageSource = "aosp"
|
||||
require64Bit = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.androidx.benchmark.macro.junit4)
|
||||
implementation(libs.androidx.profileinstaller)
|
||||
implementation(libs.androidx.test.core)
|
||||
implementation(libs.androidx.test.ext.junit)
|
||||
implementation(libs.androidx.test.espresso.core)
|
||||
implementation(libs.androidx.test.rules)
|
||||
implementation(libs.androidx.test.runner)
|
||||
implementation(libs.androidx.test.uiautomator)
|
||||
}
|
||||
|
||||
androidComponents { beforeVariants(selector().all()) { it.enable = it.buildType == "benchmark" } }
|
|
@ -0,0 +1,3 @@
|
|||
-keep class dev.msfjarvis.claw.benchmark.BaselineProfileGenerator {
|
||||
*;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<queries>
|
||||
<package android:name="dev.msfjarvis.claw.android" />
|
||||
</queries>
|
||||
</manifest>
|
|
@ -0,0 +1,36 @@
|
|||
package dev.msfjarvis.claw.benchmark
|
||||
|
||||
import androidx.benchmark.macro.BaselineProfileMode
|
||||
import androidx.benchmark.macro.CompilationMode
|
||||
import androidx.benchmark.macro.StartupMode
|
||||
import androidx.benchmark.macro.StartupTimingMetric
|
||||
import androidx.benchmark.macro.junit4.MacrobenchmarkRule
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
class BaselineProfileBenchmark {
|
||||
@get:Rule val benchmarkRule = MacrobenchmarkRule()
|
||||
|
||||
@Test
|
||||
fun startupNoCompilation() {
|
||||
startup(CompilationMode.None())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun startupBaselineProfile() {
|
||||
startup(CompilationMode.Partial(baselineProfileMode = BaselineProfileMode.Require))
|
||||
}
|
||||
|
||||
private fun startup(compilationMode: CompilationMode) {
|
||||
benchmarkRule.measureRepeated(
|
||||
packageName = PACKAGE_NAME,
|
||||
metrics = listOf(StartupTimingMetric()),
|
||||
iterations = 10,
|
||||
startupMode = StartupMode.COLD,
|
||||
compilationMode = compilationMode
|
||||
) {
|
||||
pressHome()
|
||||
startActivityAndWait()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package dev.msfjarvis.claw.benchmark
|
||||
|
||||
import androidx.benchmark.macro.ExperimentalBaselineProfilesApi
|
||||
import androidx.benchmark.macro.junit4.BaselineProfileRule
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.uiautomator.UiDevice
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
@ExperimentalBaselineProfilesApi
|
||||
class BaselineProfileGenerator {
|
||||
@get:Rule val baselineProfileRule = BaselineProfileRule()
|
||||
private lateinit var device: UiDevice
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
val instrumentation = InstrumentationRegistry.getInstrumentation()
|
||||
device = UiDevice.getInstance(instrumentation)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun startup() =
|
||||
baselineProfileRule.collectBaselineProfile(packageName = PACKAGE_NAME) {
|
||||
tapNavigationDestinations(device)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package dev.msfjarvis.claw.benchmark
|
||||
|
||||
import androidx.benchmark.macro.MacrobenchmarkScope
|
||||
import androidx.test.uiautomator.By
|
||||
import androidx.test.uiautomator.UiDevice
|
||||
|
||||
const val PACKAGE_NAME = "dev.msfjarvis.claw.android"
|
||||
|
||||
fun MacrobenchmarkScope.tapNavigationDestinations(device: UiDevice) {
|
||||
startActivityAndWait()
|
||||
device.run {
|
||||
listOf("HOTTEST", "NEWEST", "SAVED").forEach { desc ->
|
||||
findObject(By.desc(desc)).click()
|
||||
waitForIdle()
|
||||
}
|
||||
}
|
||||
device.waitForIdle()
|
||||
}
|
|
@ -5,4 +5,5 @@ plugins {
|
|||
// id("dev.msfjarvis.claw.versions")
|
||||
id("dev.msfjarvis.claw.kotlin-common")
|
||||
alias(libs.plugins.hilt) apply false
|
||||
alias(libs.plugins.android.test) apply false
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
[versions]
|
||||
accompanist = "0.24.6-alpha"
|
||||
agp = "7.4.0-alpha05"
|
||||
androidXTest = "1.4.0"
|
||||
aurora = "1.1.0"
|
||||
coil = "2.1.0"
|
||||
coroutines = "1.6.1"
|
||||
|
@ -17,6 +19,7 @@ workmanager = "2.8.0-alpha02"
|
|||
accompanist-swiperefresh = { module = "com.google.accompanist:accompanist-swiperefresh", version.ref = "accompanist" }
|
||||
accompanist-sysuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanist" }
|
||||
androidx-activity-compose = "androidx.activity:activity-compose:1.4.0"
|
||||
androidx-benchmark-macro-junit4 = "androidx.benchmark:benchmark-macro-junit4:1.1.0-beta05"
|
||||
androidx-browser = "androidx.browser:browser:1.4.0"
|
||||
androidx-core-splashscreen = "androidx.core:core-splashscreen:1.0.0-beta02"
|
||||
androidx-hilt-compiler = { module = "androidx.hilt:hilt-compiler", version.ref = "hilt" }
|
||||
|
@ -24,11 +27,18 @@ androidx-hilt-work = { module = "androidx.hilt:hilt-work", version.ref = "hilt"
|
|||
androidx-lifecycle-compose = "androidx.lifecycle:lifecycle-viewmodel-compose:2.5.0-rc01"
|
||||
androidx-navigation-compose = "androidx.navigation:navigation-compose:2.5.0-rc01"
|
||||
androidx-paging-compose = "androidx.paging:paging-compose:1.0.0-alpha14"
|
||||
androidx-profileinstaller = "androidx.profileinstaller:profileinstaller:1.2.0-beta01"
|
||||
androidx-test-core = { module = "androidx.test:core", version.ref = "androidXTest" }
|
||||
androidx-test-ext-junit = "androidx.test.ext:junit:1.1.3"
|
||||
androidx-test-espresso-core = "androidx.test.espresso:espresso-core:3.4.0"
|
||||
androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidXTest" }
|
||||
androidx-test-rules = { module = "androidx.test:rules", version.ref = "androidXTest" }
|
||||
androidx-test-uiautomator = "androidx.test.uiautomator:uiautomator:2.2.0"
|
||||
androidx-work-runtime-ktx = { module = "androidx.work:work-runtime-ktx", version.ref = "workmanager" }
|
||||
aurora-component = { module = "org.pushing-pixels:aurora-component", version.ref = "aurora" }
|
||||
aurora-theming = { module = "org.pushing-pixels:aurora-theming", version.ref = "aurora" }
|
||||
aurora-window = { module = "org.pushing-pixels:aurora-window", version.ref = "aurora" }
|
||||
build-agp = "com.android.tools.build:gradle:7.4.0-alpha05"
|
||||
build-agp = { module = "com.android.tools.build:gradle", version.ref = "agp" }
|
||||
build-kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
||||
build-kotlin-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" }
|
||||
build-spotless = "com.diffplug.spotless:spotless-plugin-gradle:6.7.2"
|
||||
|
@ -58,6 +68,7 @@ sqldelight-jvmDriver = { module = "app.cash.sqldelight:sqlite-driver", version.r
|
|||
sqldelight-primitiveAdapters = { module = "app.cash.sqldelight:primitive-adapters", version.ref = "sqldelight" }
|
||||
|
||||
[plugins]
|
||||
android-test = { id = "com.android.test", version.ref = "agp" }
|
||||
compose = "org.jetbrains.compose:1.1.1"
|
||||
hilt = { id = "com.google.dagger.hilt.android", version.ref = "dagger" }
|
||||
sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" }
|
||||
|
|
|
@ -17,6 +17,7 @@ pluginManagement {
|
|||
includeGroup("com.android.tools.lint")
|
||||
includeGroup("com.android.tools.utp")
|
||||
includeGroup("com.google.testing.platform")
|
||||
includeModule("com.android.test", "com.android.test.gradle.plugin")
|
||||
}
|
||||
}
|
||||
exclusiveContent {
|
||||
|
@ -43,11 +44,14 @@ dependencyResolutionManagement {
|
|||
includeGroup("com.android.tools.analytics-library")
|
||||
includeGroup("com.android.tools.build")
|
||||
includeGroup("com.android.tools.ddms")
|
||||
includeGroup("com.android.tools.emulator")
|
||||
includeGroup("com.android.tools.external.com-intellij")
|
||||
includeGroup("com.android.tools.external.org-jetbrains")
|
||||
includeGroup("com.android.tools.layoutlib")
|
||||
includeGroup("com.android.tools.lint")
|
||||
includeGroup("com.android.tools.utp")
|
||||
includeGroup("com.google.android.gms")
|
||||
includeGroup("com.google.testing.platform")
|
||||
includeModule("com.google.android.material", "material")
|
||||
includeGroupByRegex("androidx.*")
|
||||
}
|
||||
|
@ -71,6 +75,8 @@ include(":android")
|
|||
|
||||
include(":api")
|
||||
|
||||
include(":benchmark")
|
||||
|
||||
include(":common")
|
||||
|
||||
include(":database")
|
||||
|
|
Loading…
Reference in New Issue