Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update baseline profiles command, update README with new UI prevviews #58

Merged
merged 1 commit into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build-beta-upload-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ jobs:
run: ./gradlew :app:generateBaselineProfile
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect"
-Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true
-Pandroid.experimental.androidTest.numManagedDeviceShards=1
-Pandroid.experimental.testOptions.managedDevices.maxConcurrentDevices=1
-Pandroid.experimental.testOptions.managedDevices.setupTimeoutMinutes=5
# -Pandroid.experimental.androidTest.numManagedDeviceShards=1
# -Pandroid.experimental.testOptions.managedDevices.maxConcurrentDevices=1
# -Pandroid.experimental.testOptions.managedDevices.setupTimeoutMinutes=5

- name: Build & deploy Android release
run: bundle exec fastlane android beta
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build-production-upload-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ jobs:
run: ./gradlew :app:generateBaselineProfile
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect"
-Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true
-Pandroid.experimental.androidTest.numManagedDeviceShards=1
-Pandroid.experimental.testOptions.managedDevices.maxConcurrentDevices=1
-Pandroid.experimental.testOptions.managedDevices.setupTimeoutMinutes=5
# -Pandroid.experimental.androidTest.numManagedDeviceShards=1
# -Pandroid.experimental.testOptions.managedDevices.maxConcurrentDevices=1
# -Pandroid.experimental.testOptions.managedDevices.setupTimeoutMinutes=5

- name: Build & deploy Android release
run: bundle exec fastlane android deploy
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ Feel free to request features or suggestions for improvements.

### UIs

| ![Preview](images/map-view.png) | ![Preview](images/otp-code-verify.png) | ![Preview](images/web-view.png) |
|:-------------------------------:|:--------------------------------------:|:-------------------------------:|
| ![Map View](images/map-view.png) | ![OTP code verify](images/otp-code-verify.png) | ![Web View](images/web-view.png) |
|:--------------------------------:|:----------------------------------------------:|:--------------------------------:|
| ![Pager](images/pager.mp4) | | |

### Tutorials

Expand All @@ -77,7 +78,7 @@ Feel free to request features or suggestions for improvements.
| ![Counter](images/counter.gif) | ![Animated Visibility](images/animated-visibility.gif) | ![Lottie](images/lottie.gif) |
|:------------------------------------:|:------------------------------------------------------:|:----------------------------:|
| ![Exo Player](images/exo-player.gif) | ![Tic-Tac-Toe](images/tic-tac-toe.gif) | ![CMS](images/cms.gif) |
| ![Deep Links](images/deep-links.gif) | | |
| ![Deep Links](images/deep-links.gif) | ![Barcode Scanner](images/barcode_scanner.mp4) | |

# TODO

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ fun MacrobenchmarkScope.commonModuleTraverseActions(
val count = items.count()

for (i in 0..<count) {
Log.d("BaselineProfileGenerator", "item index: $i")

device.waitAndFindObject(By.res(screenTag), 5_000)
val items = device.waitAndFindObjects(By.res("list-item"), 5_000)
device.clickAndWaitForIdle(items[i])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,106 +1,106 @@
/*
* Copyright 2024 Md. Mahmudul Hasan Shohag
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ------------------------------------------------------------------------
*
* Project: Why Not Compose!
* Developed by: @ImaginativeShohag
*
* Md. Mahmudul Hasan Shohag
* [email protected]
*
* Source: https://github.com/ImaginativeShohag/Why-Not-Compose
*/

package org.imaginativeworld.whynotcompose.benchmarks.baselineprofile

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 androidx.test.uiautomator.By
import org.imaginativeworld.whynotcompose.benchmarks.commonModuleTraverseActions
import org.imaginativeworld.whynotcompose.benchmarks.startActivityAndAllowNotifications
import org.imaginativeworld.whynotcompose.benchmarks.waitAndFindObject
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 [org.imaginativeworld.whynotcompose.benchmarks.startup.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 AnimationsModuleBaselineProfile {

@get:Rule
val rule = BaselineProfileRule()

@Test
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()
startActivityAndAllowNotifications()

// 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

// Wait for home screen
device.waitAndFindObject(By.res("screen:home"), 5_000)

commonModuleTraverseActions(
moduleButtonText = "Animations",
screenTag = "screen:animations:index"
)
}
}
}
// /*
// * Copyright 2024 Md. Mahmudul Hasan Shohag

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [ktlint] standard:no-empty-file reported by reviewdog 🐶
File 'AnimationsModuleBaselineProfile.kt' should not be empty

// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// *
// * ------------------------------------------------------------------------
// *
// * Project: Why Not Compose!
// * Developed by: @ImaginativeShohag
// *
// * Md. Mahmudul Hasan Shohag
// * [email protected]
// *
// * Source: https://github.com/ImaginativeShohag/Why-Not-Compose
// */
//
// package org.imaginativeworld.whynotcompose.benchmarks.baselineprofile
//
// 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 androidx.test.uiautomator.By
// import org.imaginativeworld.whynotcompose.benchmarks.commonModuleTraverseActions
// import org.imaginativeworld.whynotcompose.benchmarks.startActivityAndAllowNotifications
// import org.imaginativeworld.whynotcompose.benchmarks.waitAndFindObject
// 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 [org.imaginativeworld.whynotcompose.benchmarks.startup.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 AnimationsModuleBaselineProfile {
//
// @get:Rule
// val rule = BaselineProfileRule()
//
// @Test
// 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()
// startActivityAndAllowNotifications()
//
// // 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
//
// // Wait for home screen
// device.waitAndFindObject(By.res("screen:home"), 5_000)
//
// commonModuleTraverseActions(
// moduleButtonText = "Animations",
// screenTag = "screen:animations:index"
// )
// }
// }
// }
Loading
Loading