Skip to content

Commit

Permalink
Updates (#269)
Browse files Browse the repository at this point in the history
* Version upgrades

* Introduce stable iterations

* Add startup profile collection
  • Loading branch information
keyboardsurfer committed Feb 29, 2024
1 parent 6555fe3 commit e6877a6
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 15 deletions.
2 changes: 1 addition & 1 deletion MacrobenchmarkSample/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ android {
applicationId = "com.example.macrobenchmark.target"
versionCode = 1
versionName = "1.0"
minSdk = 21 // Minimum SDK for target application can be lower than for benchmarks.
minSdk = 24
targetSdk = 34
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
18 changes: 9 additions & 9 deletions MacrobenchmarkSample/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
[versions]
agp = "8.1.4"
activity = "1.7.2"
agp = "8.2.2"
activity = "1.8.2"
appcompat = "1.6.1"
benchmark = "1.2.1"
composeBom = "2023.10.01"
benchmark = "1.2.3"
composeBom = "2024.01.00"
composeCompiler = "1.5.4"
constraintLayout = "2.1.4"
core = "1.12.0"
coroutines = "1.6.4"
coroutines = "1.7.3"
concurrentFutures = "1.1.0"
curtains = "1.2.4"
dataStore = "1.0.0"
espressoCore = "3.5.1"
jUnit = "1.1.5"
kotlin = "1.9.20"
lifecycle = "2.6.2"
material = "1.9.0"
lifecycle = "2.7.0"
material = "1.11.0"
profileInstaller = "1.3.1"
rules = "1.5.0"
runtimeTracing = "1.0.0-alpha05"
runtimeTracing = "1.0.0-beta01"
tracing = "1.3.0-alpha02"
tracingPerfetto = "1.0.0"
uiAutomator = "2.3.0-alpha05"
uiAutomator = "2.3.0-beta01"

[libraries]
androidx-rules = { module = "androidx.test:rules", version.ref = "rules" }
Expand Down
2 changes: 1 addition & 1 deletion MacrobenchmarkSample/macrobenchmark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ android {
defaultConfig {
// Minimum supported version for Baseline Profiles.
// On lower APIs, apps are fully AOT compile, therefore Baseline Profiles aren't needed.
minSdk = 24
minSdk = 28
targetSdk = 34
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package com.example.macrobenchmark.baselineprofile

import android.os.Build
import androidx.annotation.RequiresApi
import androidx.benchmark.macro.MacrobenchmarkScope
import androidx.benchmark.macro.junit4.BaselineProfileRule
import androidx.test.ext.junit.runners.AndroidJUnit4
Expand All @@ -30,7 +28,6 @@ import org.junit.runner.RunWith
* start generating a profile directly by implementing [MacrobenchmarkScope.profileBlock].
*/
@RunWith(AndroidJUnit4::class)
@RequiresApi(Build.VERSION_CODES.P)
abstract class BaselineProfileGeneratorScaffold {

@get:Rule
Expand All @@ -45,7 +42,8 @@ abstract class BaselineProfileGeneratorScaffold {
fun profileGenerator() {
rule.collect(
packageName = TARGET_PACKAGE,
maxIterations = 10
maxIterations = 15,
stableIterations = 3
) {
profileBlock()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2024 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.
*/

package com.example.macrobenchmark.baselineprofile

import androidx.benchmark.macro.junit4.BaselineProfileRule
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

/**
* Generates a startup profile.
* See
* [the documentation](https://d.android.com//topic/performance/baselineprofiles/dex-layout-optimizations)
* for details.
*/
@RunWith(AndroidJUnit4ClassRunner::class)
class StartupProfileGenerator {
@get:Rule
val rule = BaselineProfileRule()

@Test
fun profileGenerator() {
rule.collect(
packageName = TARGET_PACKAGE,
maxIterations = 15,
stableIterations = 3,
includeInStartupProfile = true
) {
startActivityAndWait()
}
}
}

0 comments on commit e6877a6

Please sign in to comment.