Skip to content

Commit ef15ea6

Browse files
committed
feat: Add Baseline Profile generation
* The Baseline Profile generation is added in the project * Update baselineprofile module to use connected devices for test execution. * Create a new shell script `generateBaselineProfile.sh` to install app and baseline profile and pull file to `baseline-prof.txt` * Modify `generate-baseline-profile.yml` github workflow to generate profile on device using `reactivecircus/android-emulator-runner` action * Fix the package name to `com.yogeshpaliyal.keypass` in `BaselineProfileGenerator.kt` to pull the data.
1 parent 630d880 commit ef15ea6

File tree

4 files changed

+37
-17
lines changed

4 files changed

+37
-17
lines changed

.github/workflows/generate-baseline-profile.yml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,31 @@ jobs:
1919
- name: Accept Android licenses
2020
run: yes | "$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager --licenses || true
2121

22-
- name: Setup GMD
23-
run: ./gradlew :baselineprofile:pixel6Api34Setup
24-
--info
25-
-Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true
26-
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect"
27-
28-
- name: Build all build type and flavor permutations including baseline profiles
29-
run: ./gradlew :app:assemble
30-
-Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=baselineprofile
31-
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect"
32-
-Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true
33-
22+
# Now use reactivecircus/android-emulator-runner to spin up an emulator and run our
23+
# baseline profile generator. We need to manually pull the baseline profiles off the
24+
# emulator when using the GA runner
25+
- name: Run benchmark
26+
uses: reactivecircus/android-emulator-runner@v2
27+
with:
28+
api-level: 34
29+
target: google_apis
30+
arch: x86_64
31+
profile: Pixel 6
32+
script: |
33+
./gradlew :app:generateFreeReleaseBaselineProfile
34+
#
35+
# - name: Setup GMD
36+
# run: ./gradlew :baselineprofile:pixel6Api34Setup
37+
# --info
38+
# -Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true
39+
# -Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect"
40+
#
41+
# - name: Build all build type and flavor permutations including baseline profiles
42+
# run: ./gradlew :app:assemble
43+
# -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=baselineprofile
44+
# -Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect"
45+
# -Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true
46+
#
3447

3548
# - name: Generate profile
3649
# run: ./gradlew :app:generateFreeReleaseBaselineProfile

baselineprofile/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ android {
5151
// You can specify to run the generators on a managed devices or connected devices.
5252
baselineProfile {
5353
// This specifies the managed devices to use that you run the tests on.
54-
managedDevices.clear()
55-
managedDevices += "pixel6Api34"
56-
useConnectedDevices = false
54+
// managedDevices.clear()
55+
// managedDevices += "pixel6Api34"
56+
useConnectedDevices = true
5757
}
5858

5959
dependencies {

baselineprofile/src/main/java/com/techpaliyal/baselineprofile/BaselineProfileGenerator.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ class BaselineProfileGenerator {
4242
fun generate() {
4343
// The application id for the running build variant is read from the instrumentation arguments.
4444
rule.collect(
45-
packageName = InstrumentationRegistry.getArguments().getString("targetAppId")
46-
?: throw Exception("targetAppId not passed as instrumentation runner arg"),
45+
packageName = "com.yogeshpaliyal.keypass",
4746

4847
// See: https://d.android.com/topic/performance/baselineprofiles/dex-layout-optimizations
4948
includeInStartupProfile = true

scripts/generateBaselineProfile.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
./gradlew :app:installFreeBenchmarkRelease
4+
5+
./gradlew :baselineprofile:installFreeBenchmarkRelease
6+
7+
./gradlew :baselineprofile:connectedFreeBenchmarkReleaseAndroidTest -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfile
8+
adb pull /sdcard/Android/media/com.yogeshpaliyal.baselineprofile app/src/main/baseline-prof.txt

0 commit comments

Comments
 (0)