Skip to content

Commit

Permalink
Merge pull request #259 from android/unify-benchmarks-in-single-module
Browse files Browse the repository at this point in the history
Unifying benchmarks in a single module
  • Loading branch information
yenerm committed Nov 14, 2023
2 parents c6f539c + 66c4e3b commit e091186
Show file tree
Hide file tree
Showing 30 changed files with 90 additions and 232 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/macrobenchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,10 @@ jobs:
- name: Build Macrobenchmark Sample
run: >
./gradlew assemble \
-x :baselineProfile:pixel6Api31NonMinifiedReleaseAndroidTest \
-x :baselineProfile:collectNonMinifiedReleaseBaselineProfile
-x :macrobenchmark:pixel6Api31NonMinifiedReleaseAndroidTest \
-x :macrobenchmark:collectNonMinifiedReleaseBaselineProfile \
-Pandroidx.benchmark.enabledRules=BaselineProfile \
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" \
-Pandroid.experimental.testOptions.managedDevices.setupTimeoutMinutes=180 \
-Pandroid.experimental.androidTest.numManagedDeviceShards=1 \
-Pandroid.experimental.testOptions.managedDevices.maxConcurrentDevices=1
2 changes: 1 addition & 1 deletion MacrobenchmarkSample/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,5 @@ dependencies {
implementation(libs.viewmodel)
androidTestImplementation(libs.benchmark.junit)

baselineProfile(project(":baselineProfile"))
baselineProfile(project(":macrobenchmark"))
}
1 change: 0 additions & 1 deletion MacrobenchmarkSample/baseBenchmarks/.gitignore

This file was deleted.

57 changes: 0 additions & 57 deletions MacrobenchmarkSample/baseBenchmarks/build.gradle.kts

This file was deleted.

Empty file.
20 changes: 0 additions & 20 deletions MacrobenchmarkSample/baseBenchmarks/src/main/AndroidManifest.xml

This file was deleted.

75 changes: 0 additions & 75 deletions MacrobenchmarkSample/baselineProfile/build.gradle.kts

This file was deleted.

23 changes: 0 additions & 23 deletions MacrobenchmarkSample/baselineProfile/src/main/AndroidManifest.xml

This file was deleted.

41 changes: 36 additions & 5 deletions MacrobenchmarkSample/macrobenchmark/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
/*
* Copyright 2023 The Android Open Source Project
*
* 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.
*/

import com.android.build.api.dsl.ManagedVirtualDevice

plugins {
id("kotlin-android")
alias(libs.plugins.test)
alias(libs.plugins.kotlin)
alias(libs.plugins.baselineprofile)
}

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

defaultConfig {
minSdk = 23 // Minimum supported version for macrobenchmark
// Minimum supported version for Baseline Profiles.
// On lower APIs, apps are fully AOT compile, therefore Baseline Profiles aren't needed.
minSdk = 24
targetSdk = 34
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

targetProjectPath = ":app"

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
jvmTarget = JavaVersion.VERSION_17.toString()
}

testOptions.managedDevices.devices {
Expand Down Expand Up @@ -54,8 +75,18 @@ android {
}
// [END macrobenchmark_setup_android]

baselineProfile {

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

// 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.
useConnectedDevices = false
}

dependencies {
implementation(project(":baseBenchmarks"))
implementation(libs.benchmark.junit)
implementation(libs.androidx.junit)
implementation(libs.espresso)
Expand Down
12 changes: 7 additions & 5 deletions MacrobenchmarkSample/macrobenchmark/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright 2022 The Android Open Source Project
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2023 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand All @@ -15,8 +16,9 @@
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<!-- Requesting legacy storage is needed to be able to write to additionalTestOutputDir on API 29 -->
<application android:requestLegacyExternalStorage="true" />

</manifest>
<queries>
<package android:name="com.example.macrobenchmark.target" />
</queries>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import androidx.benchmark.macro.MacrobenchmarkScope
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.uiautomator.By
import androidx.test.uiautomator.Direction
import com.example.benchmark.macro.base.util.findOrFail
import com.example.benchmark.macro.base.util.waitAndFind
import com.example.macrobenchmark.benchmark.util.findOrFail
import com.example.macrobenchmark.benchmark.util.waitAndFind
import org.junit.Ignore
import org.junit.runner.RunWith

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.example.macrobenchmark
package com.example.macrobenchmark.benchmark

import android.content.Intent
import android.os.Bundle
Expand All @@ -26,9 +26,9 @@ import androidx.benchmark.macro.StartupTimingMetric
import androidx.benchmark.macro.junit4.MacrobenchmarkRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.uiautomator.By
import com.example.benchmark.macro.base.util.DEFAULT_ITERATIONS
import com.example.benchmark.macro.base.util.TARGET_PACKAGE
import com.example.macrobenchmark.permissions.allowNotifications
import com.example.macrobenchmark.benchmark.util.DEFAULT_ITERATIONS
import com.example.macrobenchmark.benchmark.util.TARGET_PACKAGE
import com.example.macrobenchmark.benchmark.permissions.allowNotifications
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.example.macrobenchmark.clickslatency;
package com.example.macrobenchmark.benchmark.clickslatency;

import android.content.Intent
import androidx.benchmark.macro.CompilationMode
Expand All @@ -26,8 +26,8 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until
import com.example.benchmark.macro.base.util.DEFAULT_ITERATIONS
import com.example.benchmark.macro.base.util.TARGET_PACKAGE
import com.example.macrobenchmark.benchmark.util.DEFAULT_ITERATIONS
import com.example.macrobenchmark.benchmark.util.TARGET_PACKAGE
import junit.framework.TestCase.fail
import org.junit.Rule
import org.junit.Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.example.macrobenchmark.frames
package com.example.macrobenchmark.benchmark.frames

import android.content.Intent
import androidx.benchmark.macro.CompilationMode
Expand All @@ -25,8 +25,8 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.uiautomator.By
import androidx.test.uiautomator.Direction
import com.example.benchmark.macro.base.util.DEFAULT_ITERATIONS
import com.example.benchmark.macro.base.util.TARGET_PACKAGE
import com.example.macrobenchmark.benchmark.util.DEFAULT_ITERATIONS
import com.example.macrobenchmark.benchmark.util.TARGET_PACKAGE
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.example.macrobenchmark.frames
package com.example.macrobenchmark.benchmark.frames

import androidx.benchmark.macro.*
import androidx.benchmark.macro.junit4.MacrobenchmarkRule
Expand All @@ -23,9 +23,9 @@ import androidx.test.filters.LargeTest
import androidx.test.uiautomator.By
import androidx.test.uiautomator.Direction
import androidx.test.uiautomator.Until
import com.example.benchmark.macro.base.util.DEFAULT_ITERATIONS
import com.example.benchmark.macro.base.util.TARGET_PACKAGE
import com.example.benchmark.macro.base.util.waitAndFind
import com.example.macrobenchmark.benchmark.util.DEFAULT_ITERATIONS
import com.example.macrobenchmark.benchmark.util.TARGET_PACKAGE
import com.example.macrobenchmark.benchmark.util.waitAndFind
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand Down
Loading

0 comments on commit e091186

Please sign in to comment.