diff options
| author | JosJuice <josjuice@gmail.com> | 2022-12-10 21:09:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-10 21:09:18 +0100 |
| commit | 2b7b3c3942579cab9724a504548e4678ad43cf07 (patch) | |
| tree | f26f8b81392912d133b2f6ad300c1c8e54a27cc2 /Source/Android/benchmark/src/main/java/com | |
| parent | 932926a4aad69ffb1aa2a0667fc20ecb126575fb (diff) | |
| parent | 974003888a16b30ec1b1543a46804fa7566c8672 (diff) | |
Merge pull request #11335 from t895/baseline-profile
Android: Baseline profile generation
Diffstat (limited to 'Source/Android/benchmark/src/main/java/com')
| -rw-r--r-- | Source/Android/benchmark/src/main/java/com/dolphin/benchmark/BaselineProfileGenerator.kt | 43 | ||||
| -rw-r--r-- | Source/Android/benchmark/src/main/java/com/dolphin/benchmark/StartupBenchmark.kt | 40 |
2 files changed, 83 insertions, 0 deletions
diff --git a/Source/Android/benchmark/src/main/java/com/dolphin/benchmark/BaselineProfileGenerator.kt b/Source/Android/benchmark/src/main/java/com/dolphin/benchmark/BaselineProfileGenerator.kt new file mode 100644 index 0000000000..366a22ab6a --- /dev/null +++ b/Source/Android/benchmark/src/main/java/com/dolphin/benchmark/BaselineProfileGenerator.kt @@ -0,0 +1,43 @@ +package com.dolphin.benchmark + +import androidx.benchmark.macro.ExperimentalBaselineProfilesApi +import androidx.benchmark.macro.junit4.BaselineProfileRule +import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner +import androidx.test.uiautomator.UiSelector +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@OptIn(ExperimentalBaselineProfilesApi::class) +@RunWith(AndroidJUnit4ClassRunner::class) +class BaselineProfileGenerator { + + @get:Rule + val rule = BaselineProfileRule() + + @Test + fun generate() = rule.collectBaselineProfile( + packageName = "org.dolphinemu.dolphinemu.benchmark", + profileBlock = { + pressHome() + startActivityAndWait() + + // Dismiss analytics dialog due to issue with finding button + device.pressBack() + + // Navigate through activities that don't require games + // TODO: Make all activities testable without having games available + // TODO: Use resource strings to support more languages + + // Navigate to the Settings Activity + val settings = device.findObject(UiSelector().description("Settings")) + settings.clickAndWaitForNewWindow(30_000) + + // Go through settings and to the User Data Activity + val config = device.findObject(UiSelector().textContains("Config")) + config.click() + val userData = device.findObject(UiSelector().textContains("User Data")) + userData.clickAndWaitForNewWindow(30_000) + }, + ) +} 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 new file mode 100644 index 0000000000..5ae5d40f6b --- /dev/null +++ b/Source/Android/benchmark/src/main/java/com/dolphin/benchmark/StartupBenchmark.kt @@ -0,0 +1,40 @@ +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() + } +} |
