forked from godotengine/godot
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add macro benchmarking support for the Android editor
- Loading branch information
Showing
9 changed files
with
136 additions
and
6 deletions.
There are no files selected for viewing
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 @@ | ||
/build |
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,55 @@ | ||
plugins { | ||
id 'com.android.test' | ||
id 'org.jetbrains.kotlin.android' | ||
} | ||
|
||
android { | ||
namespace 'org.godotengine.editor.macrobenchmark' | ||
compileSdk versions.compileSdk | ||
|
||
compileOptions { | ||
sourceCompatibility versions.javaVersion | ||
targetCompatibility versions.javaVersion | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = versions.javaVersion | ||
} | ||
|
||
defaultConfig { | ||
minSdk 24 | ||
targetSdk versions.targetSdk | ||
missingDimensionStrategy 'products', 'editor' | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
testInstrumentationRunnerArguments["androidx.benchmark.suppressErrors"] = 'EMULATOR' | ||
} | ||
|
||
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 { | ||
debuggable = true | ||
signingConfig = debug.signingConfig | ||
matchingFallbacks = ["release"] | ||
} | ||
} | ||
|
||
targetProjectPath = ":editor" | ||
experimentalProperties["android.experimental.self-instrumenting"] = true | ||
} | ||
|
||
dependencies { | ||
implementation 'androidx.test:rules:1.5.0' | ||
implementation 'androidx.test.ext:junit:1.1.5' | ||
implementation 'androidx.test.espresso:espresso-core:3.5.1' | ||
implementation 'androidx.test.uiautomator:uiautomator:2.3.0' | ||
implementation 'androidx.benchmark:benchmark-macro-junit4:1.2.4' | ||
} | ||
|
||
androidComponents { | ||
beforeVariants(selector().all()) { | ||
enable = buildType == "benchmark" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
platform/android/java/editor/macrobenchmark/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 |
---|---|---|
@@ -0,0 +1 @@ | ||
<manifest /> |
57 changes: 57 additions & 0 deletions
57
...or/macrobenchmark/src/main/java/org/godotengine/editor/macrobenchmark/EditorBenchmarks.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,57 @@ | ||
package org.godotengine.editor.macrobenchmark | ||
|
||
import android.Manifest | ||
import androidx.benchmark.macro.ExperimentalMetricApi | ||
import androidx.benchmark.macro.MemoryUsageMetric | ||
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.rule.GrantPermissionRule | ||
import androidx.test.uiautomator.By | ||
import androidx.test.uiautomator.StaleObjectException | ||
import androidx.test.uiautomator.Until | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
/** | ||
* Set of editor macro benchmarks. | ||
* | ||
* Before running, switch the editor's active build variant to 'benchmark' | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class EditorBenchmarks { | ||
|
||
companion object { | ||
const val PACKAGE_NAME = "org.godotengine.editor.v4.benchmark" | ||
} | ||
|
||
@get:Rule val benchmarkRule = MacrobenchmarkRule() | ||
@get:Rule val grantPermissionRule = GrantPermissionRule.grant( | ||
Manifest.permission.READ_EXTERNAL_STORAGE, | ||
Manifest.permission.WRITE_EXTERNAL_STORAGE) | ||
|
||
/** | ||
* Navigates to the device's home screen, and launches the Project Manager. | ||
*/ | ||
@OptIn(ExperimentalMetricApi::class) | ||
@Test | ||
fun startupProjectManager() = benchmarkRule.measureRepeated( | ||
packageName = PACKAGE_NAME, | ||
metrics = listOf( | ||
StartupTimingMetric(), | ||
MemoryUsageMetric(MemoryUsageMetric.Mode.Max), | ||
), | ||
iterations = 5, | ||
startupMode = StartupMode.COLD | ||
) { | ||
pressHome() | ||
startActivityAndWait() | ||
|
||
try { | ||
val editorLoadingIndicator = device.findObject(By.res(PACKAGE_NAME, "editor_loading_indicator")) | ||
editorLoadingIndicator.wait(Until.gone(By.res(PACKAGE_NAME, "editor_loading_indicator")), 5_000) | ||
} catch (ignored: StaleObjectException) {} | ||
} | ||
} |
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
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