-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
versionName 1.0.15 add: baseline profile generator mod: emulator parameter
- Loading branch information
1 parent
8eefe7b
commit bfc6718
Showing
3 changed files
with
101 additions
and
10 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
67 changes: 67 additions & 0 deletions
67
...rofile/src/main/kotlin/com/joeloewi/jumpkking/baselineprofile/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,67 @@ | ||
package com.joeloewi.jumpkking.baselineprofile | ||
|
||
import androidx.benchmark.macro.junit4.BaselineProfileRule | ||
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 | ||
|
||
/** | ||
* This test class generates a basic startup baseline profile for the target package. | ||
* | ||
* We recommend you start with this but add important user flows to the profile to improve their performance. | ||
* Refer to the [baseline profile documentation](https://d.android.com/topic/performance/baselineprofiles) | ||
* for more information. | ||
* | ||
* You can run the generator with the Generate Baseline Profile run configuration, | ||
* or directly with `generateBaselineProfile` Gradle task: | ||
* ``` | ||
* ./gradlew :app:generateReleaseBaselineProfile -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfile | ||
* ``` | ||
* The run configuration runs the Gradle task and applies filtering to run only the generators. | ||
* | ||
* Check [documentation](https://d.android.com/topic/performance/benchmarking/macrobenchmark-instrumentation-args) | ||
* for more information about available instrumentation arguments. | ||
* | ||
* After you run the generator, you can verify the improvements running the [StartupBenchmarks] benchmark. | ||
* | ||
* When using this class to generate a baseline profile, only API 33+ or rooted API 26+ are supported. | ||
**/ | ||
@RunWith(AndroidJUnit4::class) | ||
@LargeTest | ||
class BaselineProfileGenerator { | ||
|
||
@get:Rule | ||
val rule = BaselineProfileRule() | ||
|
||
@Test | ||
fun generate() { | ||
rule.collect( | ||
packageName = "com.joeloewi.jumpkking", | ||
includeInStartupProfile = true | ||
) { | ||
pressHome() | ||
startActivityAndWait() | ||
} | ||
|
||
rule.collect("com.joeloewi.jumpkking") { | ||
// This block defines the app's critical user journey. Here we are interested in | ||
// optimizing for app startup. But you can also navigate and scroll | ||
// through your most important UI. | ||
|
||
// Start default activity for your app | ||
pressHome() | ||
startActivityAndWait() | ||
|
||
// TODO Write more interactions to optimize advanced journeys of your app. | ||
// For example: | ||
// 1. Wait until the content is asynchronously loaded | ||
// 2. Scroll the feed content | ||
// 3. Navigate to detail screen | ||
|
||
// Check UiAutomator documentation for more information how to interact with the app. | ||
// https://d.android.com/training/testing/other-components/ui-automator | ||
} | ||
} | ||
} |
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