Skip to content

Commit

Permalink
Merge pull request #531 from qdsfdhvh/master
Browse files Browse the repository at this point in the history
Version 1.8.0
  • Loading branch information
qdsfdhvh authored May 23, 2024
2 parents 32fde02 + 253d0bc commit e76e983
Show file tree
Hide file tree
Showing 33 changed files with 22,384 additions and 162 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/Check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: actions/checkout@v4

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v2
uses: gradle/wrapper-validation-action@v3

- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
Expand All @@ -46,7 +46,7 @@ jobs:
uses: actions/checkout@v4

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v2
uses: gradle/wrapper-validation-action@v3

- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
Expand All @@ -68,7 +68,7 @@ jobs:
uses: actions/checkout@v4

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v2
uses: gradle/wrapper-validation-action@v3

- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
uses: actions/checkout@v4

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v2
uses: gradle/wrapper-validation-action@v3

- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
Expand All @@ -121,7 +121,6 @@ jobs:
run: |
./gradlew kotlinUpgradeYarnLock \
:image-loader:assemble \
:extension:blur:assemble \
:extension:imageio:assemble \
:extension:moko-resources:assemble \
--stacktrace -PnoAppApple \
Expand All @@ -135,7 +134,7 @@ jobs:
uses: actions/checkout@v4

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v2
uses: gradle/wrapper-validation-action@v3

- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
Expand All @@ -160,7 +159,6 @@ jobs:
run: |
./gradlew kotlinUpgradeYarnLock \
:image-loader:build \
:extension:blur:build \
:extension:imageio:build \
:extension:moko-resources:build \
--stacktrace -PnoAppApple \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/CompareScreenshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: Set up JDK 17
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
Expand All @@ -30,7 +30,7 @@ jobs:
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@29c0906b64b8fc82467890bfb7a0a7ef34bda89e # v3.1.0
uses: gradle/gradle-build-action@4c39dd82cd5e1ec7c6fa0173bb41b4b6bb3b86ff # v3.3.2
with:
gradle-version: wrapper

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CompareScreenshotComment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
echo "pull_request_number=$(cat NR)" >> "$GITHUB_OUTPUT"
- name: master checkout
id: checkout-master
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: master
- id: switch-companion-branch
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/DocsDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v2
uses: gradle/wrapper-validation-action@v3

- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
working-directory: ./docs

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/DocsTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v2
uses: gradle/wrapper-validation-action@v3

- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/Publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: actions/checkout@v4

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v2
uses: gradle/wrapper-validation-action@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
Expand Down Expand Up @@ -56,6 +56,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
body: ${{ steps.github_release.outputs.changelog }}
4 changes: 2 additions & 2 deletions .github/workflows/StoreScreenshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: Set up JDK 17
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
Expand All @@ -33,7 +33,7 @@ jobs:

# Better than caching and/or extensions of actions/setup-java
- name: Setup Gradle
uses: gradle/gradle-build-action@29c0906b64b8fc82467890bfb7a0a7ef34bda89e # v3.1.0
uses: gradle/gradle-build-action@4c39dd82cd5e1ec7c6fa0173bb41b4b6bb3b86ff # v3.3.2
with:
gradle-version: wrapper

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ publish.properties

# Moko
moko-resources-generated.js

# Kotlin
/.kotlin
44 changes: 27 additions & 17 deletions app/android/benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,35 @@ plugins {
}

android {
namespace = "com.seiko.imageloader.demo.benchmark"
namespace = "com.seiko.imageloader.demo.baselineprofile"
compileSdk = 34
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}
defaultConfig {
minSdk = 23
minSdk = 28
targetSdk = 34
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")
}
}
testOptions.managedDevices.devices {
create<ManagedVirtualDevice>("pixel6proApi31").apply {
device = "Pixel 6 Pro"
apiLevel = 31
@Suppress("UnstableApiUsage")
create<ManagedVirtualDevice>("pixel6Api32").apply {
device = "Pixel 6"
apiLevel = 32
systemImageSource = "aosp"
}
}
targetProjectPath = ":app:android"
experimentalProperties["android.experimental.self-instrumenting"] = true
}

baselineProfile {
// This specifies the managed devices to use that you run the tests on. The default
// is none.
managedDevices += "pixel6proApi31"
managedDevices += "pixel6Api32"

// This enables using connected devices to generate profiles. The default is true.
// When using connected devices, they must be rooted or API 33 and higher.
Expand All @@ -48,7 +47,18 @@ baselineProfile {

dependencies {
implementation(libs.androidx.test.junit)
implementation(libs.androidx.test.espresso)
implementation(libs.androidx.test.uiautomator)
implementation(libs.androidx.benchmark.macro.junit4)
implementation(libs.androidx.profileinstaller)
}

androidComponents {
onVariants { v ->
val artifactsLoader = v.artifacts.getBuiltArtifactsLoader()
v.instrumentationRunnerArguments.put(
"targetAppId",
v.testedApks.map { artifactsLoader.load(it)?.applicationId!! },
)
}
}
8 changes: 1 addition & 7 deletions app/android/benchmark/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<queries>
<package android:name="com.seiko.imageloader.demo" />
</queries>
</manifest>
<manifest />
Original file line number Diff line number Diff line change
@@ -1,24 +1,68 @@
package com.seiko.imageloader.demo.benchmark

import androidx.benchmark.macro.junit4.BaselineProfileRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.platform.app.InstrumentationRegistry
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 in Android Studio or
* the equivalent `generateBaselineProfile` gradle task:
* ```
* ./gradlew :app:generateReleaseBaselineProfile
* ```
* 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 28+ are supported.
*
* The minimum required version of androidx.benchmark to generate a baseline profile is 1.2.0.
**/
@RunWith(AndroidJUnit4::class)
@LargeTest
class BaselineProfileGenerator {

@get:Rule
val baselineProfileRule = BaselineProfileRule()
val rule = BaselineProfileRule()

@Test
fun startupBaselineProfile() =
baselineProfileRule.collect(
packageName = "com.seiko.imageloader.demo",
// Iteration values recommended by AndroidX folks
maxIterations = 15,
stableIterations = 3,
profileBlock = {
pressHome()
startActivityAndWait()
device.waitForIdle()
},
)
fun generate() {
// The application id for the running build variant is read from the instrumentation arguments.
rule.collect(
packageName = InstrumentationRegistry.getArguments().getString("targetAppId")
?: throw Exception("targetAppId not passed as instrumentation runner arg"),

// See: https://d.android.com/topic/performance/baselineprofiles/dex-layout-optimizations
includeInStartupProfile = true,
) {
// 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
}
}
}
Loading

0 comments on commit e76e983

Please sign in to comment.