summaryrefslogtreecommitdiff
path: root/Source/Android/benchmark
diff options
context:
space:
mode:
authorOatmealDome <OatmealDome@users.noreply.github.com>2023-12-10 11:17:56 -0500
committerGitHub <noreply@github.com>2023-12-10 11:17:56 -0500
commitd272b0ef84e62ad91bbdc0c5ec10f2f772d455ac (patch)
tree58e87455354fc2938f5dbf597155485534539fa5 /Source/Android/benchmark
parente2472e4f50c749585ffc200ed8646d258c3627c7 (diff)
parent93a5df3b9229490e782c3c290be133c81877b5b3 (diff)
Merge pull request #12183 from t895/gradle-kotlin-dsl
Android: Gradle updates
Diffstat (limited to 'Source/Android/benchmark')
-rw-r--r--Source/Android/benchmark/.gitignore2
-rw-r--r--Source/Android/benchmark/build.gradle71
-rw-r--r--Source/Android/benchmark/build.gradle.kts52
-rw-r--r--Source/Android/benchmark/src/main/AndroidManifest.xml7
-rw-r--r--Source/Android/benchmark/src/main/java/com/dolphin/benchmark/StartupBenchmark.kt40
-rw-r--r--Source/Android/benchmark/src/main/java/org/dolphinemu/baselineprofile/BaselineProfileGenerator.kt (renamed from Source/Android/benchmark/src/main/java/com/dolphin/benchmark/BaselineProfileGenerator.kt)23
-rw-r--r--Source/Android/benchmark/src/main/java/org/dolphinemu/baselineprofile/StartupBenchmarks.kt46
7 files changed, 112 insertions, 129 deletions
diff --git a/Source/Android/benchmark/.gitignore b/Source/Android/benchmark/.gitignore
index 796b96d1c4..42afabfd2a 100644
--- a/Source/Android/benchmark/.gitignore
+++ b/Source/Android/benchmark/.gitignore
@@ -1 +1 @@
-/build
+/build \ No newline at end of file
diff --git a/Source/Android/benchmark/build.gradle b/Source/Android/benchmark/build.gradle
deleted file mode 100644
index 13a94f5621..0000000000
--- a/Source/Android/benchmark/build.gradle
+++ /dev/null
@@ -1,71 +0,0 @@
-import com.android.build.api.dsl.ManagedVirtualDevice
-
-plugins {
- id 'com.android.test'
- id 'org.jetbrains.kotlin.android'
-}
-
-android {
- namespace 'com.dolphin.benchmark'
- compileSdk 33
-
- compileOptions {
- sourceCompatibility = "11"
- targetCompatibility = "11"
- }
-
- kotlinOptions {
- jvmTarget = "11"
- }
-
- defaultConfig {
- minSdk 23
- targetSdk 33
-
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
- }
-
- testOptions {
- managedDevices {
- devices {
- pixel6Api31 (ManagedVirtualDevice) {
- device = "Pixel 6"
- apiLevel = 31
- systemImageSource = "aosp"
- }
- }
- }
- }
-
- 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.
- benchmark {
- signingConfig signingConfigs.debug
- matchingFallbacks = ['release']
- debuggable true
- proguardFiles getDefaultProguardFile(
- 'proguard-android-optimize.txt'),
- 'proguard-rules.pro'
- minifyEnabled true
- shrinkResources true
- }
- }
-
- targetProjectPath = ":app"
- experimentalProperties["android.experimental.self-instrumenting"] = true
-}
-
-dependencies {
- implementation 'androidx.test.ext:junit:1.1.5'
- implementation 'androidx.test.espresso:espresso-core:3.5.1'
- implementation 'androidx.test.uiautomator:uiautomator:2.2.0'
- implementation 'androidx.benchmark:benchmark-macro-junit4:1.1.1'
-}
-
-androidComponents {
- beforeVariants(selector().all()) {
- enabled = buildType == "benchmark"
- }
-}
diff --git a/Source/Android/benchmark/build.gradle.kts b/Source/Android/benchmark/build.gradle.kts
new file mode 100644
index 0000000000..0065dadb0f
--- /dev/null
+++ b/Source/Android/benchmark/build.gradle.kts
@@ -0,0 +1,52 @@
+import com.android.build.api.dsl.ManagedVirtualDevice
+
+plugins {
+ id("com.android.test")
+ id("org.jetbrains.kotlin.android")
+ id("androidx.baselineprofile")
+}
+
+android {
+ namespace = "org.dolphinemu.baselineprofile"
+ compileSdk = 34
+
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
+ }
+
+ kotlinOptions {
+ jvmTarget = "17"
+ }
+
+ defaultConfig {
+ minSdk = 28
+ targetSdk = 34
+
+ testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
+ }
+
+ targetProjectPath = ":app"
+
+ testOptions.managedDevices.devices {
+ create<ManagedVirtualDevice>("pixel6Api31") {
+ device = "Pixel 6"
+ apiLevel = 31
+ systemImageSource = "google"
+ }
+ }
+}
+
+// This is the configuration block for the Baseline Profile plugin.
+// You can specify to run the generators on a managed devices or connected devices.
+baselineProfile {
+ managedDevices += "pixel6Api31"
+ useConnectedDevices = false
+}
+
+dependencies {
+ implementation("androidx.test.ext:junit:1.1.5")
+ implementation("androidx.test.espresso:espresso-core:3.5.1")
+ implementation("androidx.test.uiautomator:uiautomator:2.2.0")
+ implementation("androidx.benchmark:benchmark-macro-junit4:1.2.2")
+}
diff --git a/Source/Android/benchmark/src/main/AndroidManifest.xml b/Source/Android/benchmark/src/main/AndroidManifest.xml
index 8f83f3238c..cc947c5679 100644
--- a/Source/Android/benchmark/src/main/AndroidManifest.xml
+++ b/Source/Android/benchmark/src/main/AndroidManifest.xml
@@ -1,6 +1 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android">
- <queries>
- <package android:name="org.dolphinemu.dolphinemu.debug" />
- </queries>
-</manifest>
+<manifest />
diff --git a/Source/Android/benchmark/src/main/java/com/dolphin/benchmark/StartupBenchmark.kt b/Source/Android/benchmark/src/main/java/com/dolphin/benchmark/StartupBenchmark.kt
deleted file mode 100644
index 5ae5d40f6b..0000000000
--- a/Source/Android/benchmark/src/main/java/com/dolphin/benchmark/StartupBenchmark.kt
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.dolphin.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 androidx.test.ext.junit.runners.AndroidJUnit4
-import org.junit.Rule
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@RunWith(AndroidJUnit4::class)
-class StartupBenchmark {
- @get:Rule
- val benchmarkRule = MacrobenchmarkRule()
-
- @Test
- fun startupBaselineProfileDisabled() = startup(
- CompilationMode.Partial(baselineProfileMode = BaselineProfileMode.Disable, warmupIterations = 1)
- )
-
- @Test
- fun startupBaselineProfile() = startup(
- CompilationMode.Partial(baselineProfileMode = BaselineProfileMode.Require, warmupIterations = 1)
- )
-
- private fun startup(compilationMode: CompilationMode) = benchmarkRule.measureRepeated(
- packageName = "org.dolphinemu.dolphinemu.benchmark",
- metrics = listOf(StartupTimingMetric()),
- iterations = 10,
- compilationMode = compilationMode,
- startupMode = StartupMode.COLD,
- setupBlock = {
- pressHome()
- }
- ) {
- startActivityAndWait()
- }
-}
diff --git a/Source/Android/benchmark/src/main/java/com/dolphin/benchmark/BaselineProfileGenerator.kt b/Source/Android/benchmark/src/main/java/org/dolphinemu/baselineprofile/BaselineProfileGenerator.kt
index 366a22ab6a..9bf621d6c1 100644
--- a/Source/Android/benchmark/src/main/java/com/dolphin/benchmark/BaselineProfileGenerator.kt
+++ b/Source/Android/benchmark/src/main/java/org/dolphinemu/baselineprofile/BaselineProfileGenerator.kt
@@ -1,24 +1,25 @@
-package com.dolphin.benchmark
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+package org.dolphinemu.baselineprofile
-import androidx.benchmark.macro.ExperimentalBaselineProfilesApi
import androidx.benchmark.macro.junit4.BaselineProfileRule
-import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.LargeTest
import androidx.test.uiautomator.UiSelector
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
-@OptIn(ExperimentalBaselineProfilesApi::class)
-@RunWith(AndroidJUnit4ClassRunner::class)
+@RunWith(AndroidJUnit4::class)
+@LargeTest
class BaselineProfileGenerator {
@get:Rule
val rule = BaselineProfileRule()
@Test
- fun generate() = rule.collectBaselineProfile(
- packageName = "org.dolphinemu.dolphinemu.benchmark",
- profileBlock = {
+ fun generate() {
+ rule.collect("org.dolphinemu.dolphinemu") {
pressHome()
startActivityAndWait()
@@ -26,7 +27,7 @@ class BaselineProfileGenerator {
device.pressBack()
// Navigate through activities that don't require games
- // TODO: Make all activities testable without having games available
+ // TODO: Make all activities testable without having games available (or use homebrew)
// TODO: Use resource strings to support more languages
// Navigate to the Settings Activity
@@ -38,6 +39,6 @@ class BaselineProfileGenerator {
config.click()
val userData = device.findObject(UiSelector().textContains("User Data"))
userData.clickAndWaitForNewWindow(30_000)
- },
- )
+ }
+ }
}
diff --git a/Source/Android/benchmark/src/main/java/org/dolphinemu/baselineprofile/StartupBenchmarks.kt b/Source/Android/benchmark/src/main/java/org/dolphinemu/baselineprofile/StartupBenchmarks.kt
new file mode 100644
index 0000000000..359a3df584
--- /dev/null
+++ b/Source/Android/benchmark/src/main/java/org/dolphinemu/baselineprofile/StartupBenchmarks.kt
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+package org.dolphinemu.baselineprofile
+
+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 androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.LargeTest
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+@LargeTest
+class StartupBenchmarks {
+
+ @get:Rule
+ val rule = MacrobenchmarkRule()
+
+ @Test
+ fun startupCompilationNone() =
+ benchmark(CompilationMode.None())
+
+ @Test
+ fun startupCompilationBaselineProfiles() =
+ benchmark(CompilationMode.Partial(BaselineProfileMode.Require))
+
+ private fun benchmark(compilationMode: CompilationMode) {
+ rule.measureRepeated(
+ packageName = "org.dolphinemu.dolphinemu",
+ metrics = listOf(StartupTimingMetric()),
+ compilationMode = compilationMode,
+ startupMode = StartupMode.COLD,
+ iterations = 10,
+ setupBlock = {
+ pressHome()
+ },
+ measureBlock = {
+ startActivityAndWait()
+ }
+ )
+ }
+}