Skip to content

Commit e091186

Browse files
author
Murat Yener
authored
Merge pull request #259 from android/unify-benchmarks-in-single-module
Unifying benchmarks in a single module
2 parents c6f539c + 66c4e3b commit e091186

30 files changed

+90
-232
lines changed

.github/workflows/macrobenchmark.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,10 @@ jobs:
5656
- name: Build Macrobenchmark Sample
5757
run: >
5858
./gradlew assemble \
59-
-x :baselineProfile:pixel6Api31NonMinifiedReleaseAndroidTest \
60-
-x :baselineProfile:collectNonMinifiedReleaseBaselineProfile
59+
-x :macrobenchmark:pixel6Api31NonMinifiedReleaseAndroidTest \
60+
-x :macrobenchmark:collectNonMinifiedReleaseBaselineProfile \
61+
-Pandroidx.benchmark.enabledRules=BaselineProfile \
62+
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" \
63+
-Pandroid.experimental.testOptions.managedDevices.setupTimeoutMinutes=180 \
64+
-Pandroid.experimental.androidTest.numManagedDeviceShards=1 \
65+
-Pandroid.experimental.testOptions.managedDevices.maxConcurrentDevices=1

MacrobenchmarkSample/app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,5 @@ dependencies {
103103
implementation(libs.viewmodel)
104104
androidTestImplementation(libs.benchmark.junit)
105105

106-
baselineProfile(project(":baselineProfile"))
106+
baselineProfile(project(":macrobenchmark"))
107107
}

MacrobenchmarkSample/baseBenchmarks/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

MacrobenchmarkSample/baseBenchmarks/build.gradle.kts

Lines changed: 0 additions & 57 deletions
This file was deleted.

MacrobenchmarkSample/baseBenchmarks/consumer-rules.pro

Whitespace-only changes.

MacrobenchmarkSample/baseBenchmarks/src/main/AndroidManifest.xml

Lines changed: 0 additions & 20 deletions
This file was deleted.

MacrobenchmarkSample/baselineProfile/build.gradle.kts

Lines changed: 0 additions & 75 deletions
This file was deleted.

MacrobenchmarkSample/baselineProfile/src/main/AndroidManifest.xml

Lines changed: 0 additions & 23 deletions
This file was deleted.

MacrobenchmarkSample/macrobenchmark/build.gradle.kts

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
1+
/*
2+
* Copyright 2023 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
import com.android.build.api.dsl.ManagedVirtualDevice
218

319
plugins {
20+
id("kotlin-android")
421
alias(libs.plugins.test)
522
alias(libs.plugins.kotlin)
23+
alias(libs.plugins.baselineprofile)
624
}
725

826
// [START macrobenchmark_setup_android]
@@ -12,19 +30,22 @@ android {
1230
namespace = "com.example.macrobenchmark"
1331

1432
defaultConfig {
15-
minSdk = 23 // Minimum supported version for macrobenchmark
33+
// Minimum supported version for Baseline Profiles.
34+
// On lower APIs, apps are fully AOT compile, therefore Baseline Profiles aren't needed.
35+
minSdk = 24
1636
targetSdk = 34
1737
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
1838
}
1939

2040
targetProjectPath = ":app"
2141

2242
compileOptions {
23-
sourceCompatibility = JavaVersion.VERSION_11
24-
targetCompatibility = JavaVersion.VERSION_11
43+
sourceCompatibility = JavaVersion.VERSION_17
44+
targetCompatibility = JavaVersion.VERSION_17
2545
}
46+
2647
kotlinOptions {
27-
jvmTarget = JavaVersion.VERSION_11.toString()
48+
jvmTarget = JavaVersion.VERSION_17.toString()
2849
}
2950

3051
testOptions.managedDevices.devices {
@@ -54,8 +75,18 @@ android {
5475
}
5576
// [END macrobenchmark_setup_android]
5677

78+
baselineProfile {
79+
80+
// This specifies the managed devices to use that you run the tests on. The default
81+
// is none.
82+
managedDevices += "pixel6Api31"
83+
84+
// This enables using connected devices to generate profiles. The default is true.
85+
// When using connected devices, they must be rooted or API 33 and higher.
86+
useConnectedDevices = false
87+
}
88+
5789
dependencies {
58-
implementation(project(":baseBenchmarks"))
5990
implementation(libs.benchmark.junit)
6091
implementation(libs.androidx.junit)
6192
implementation(libs.espresso)

MacrobenchmarkSample/macrobenchmark/src/main/AndroidManifest.xml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
<?xml version="1.0" encoding="utf-8"?><!--
2-
~ Copyright 2022 The Android Open Source Project
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright 2023 The Android Open Source Project
34
~
45
~ Licensed under the Apache License, Version 2.0 (the "License");
56
~ you may not use this file except in compliance with the License.
@@ -15,8 +16,9 @@
1516
-->
1617

1718
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
18-
1919
<!-- Requesting legacy storage is needed to be able to write to additionalTestOutputDir on API 29 -->
2020
<application android:requestLegacyExternalStorage="true" />
21-
22-
</manifest>
21+
<queries>
22+
<package android:name="com.example.macrobenchmark.target" />
23+
</queries>
24+
</manifest>

0 commit comments

Comments
 (0)