Skip to content

Commit e6877a6

Browse files
Updates (#269)
* Version upgrades * Introduce stable iterations * Add startup profile collection
1 parent 6555fe3 commit e6877a6

File tree

5 files changed

+60
-15
lines changed

5 files changed

+60
-15
lines changed

MacrobenchmarkSample/app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ android {
2828
applicationId = "com.example.macrobenchmark.target"
2929
versionCode = 1
3030
versionName = "1.0"
31-
minSdk = 21 // Minimum SDK for target application can be lower than for benchmarks.
31+
minSdk = 24
3232
targetSdk = 34
3333
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
3434
}

MacrobenchmarkSample/gradle/libs.versions.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
[versions]
2-
agp = "8.1.4"
3-
activity = "1.7.2"
2+
agp = "8.2.2"
3+
activity = "1.8.2"
44
appcompat = "1.6.1"
5-
benchmark = "1.2.1"
6-
composeBom = "2023.10.01"
5+
benchmark = "1.2.3"
6+
composeBom = "2024.01.00"
77
composeCompiler = "1.5.4"
88
constraintLayout = "2.1.4"
99
core = "1.12.0"
10-
coroutines = "1.6.4"
10+
coroutines = "1.7.3"
1111
concurrentFutures = "1.1.0"
1212
curtains = "1.2.4"
1313
dataStore = "1.0.0"
1414
espressoCore = "3.5.1"
1515
jUnit = "1.1.5"
1616
kotlin = "1.9.20"
17-
lifecycle = "2.6.2"
18-
material = "1.9.0"
17+
lifecycle = "2.7.0"
18+
material = "1.11.0"
1919
profileInstaller = "1.3.1"
2020
rules = "1.5.0"
21-
runtimeTracing = "1.0.0-alpha05"
21+
runtimeTracing = "1.0.0-beta01"
2222
tracing = "1.3.0-alpha02"
2323
tracingPerfetto = "1.0.0"
24-
uiAutomator = "2.3.0-alpha05"
24+
uiAutomator = "2.3.0-beta01"
2525

2626
[libraries]
2727
androidx-rules = { module = "androidx.test:rules", version.ref = "rules" }

MacrobenchmarkSample/macrobenchmark/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ android {
3232
defaultConfig {
3333
// Minimum supported version for Baseline Profiles.
3434
// On lower APIs, apps are fully AOT compile, therefore Baseline Profiles aren't needed.
35-
minSdk = 24
35+
minSdk = 28
3636
targetSdk = 34
3737
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
3838
}

MacrobenchmarkSample/macrobenchmark/src/main/java/com/example/macrobenchmark/baselineprofile/BaselineProfileGeneratorScaffold.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package com.example.macrobenchmark.baselineprofile
1818

19-
import android.os.Build
20-
import androidx.annotation.RequiresApi
2119
import androidx.benchmark.macro.MacrobenchmarkScope
2220
import androidx.benchmark.macro.junit4.BaselineProfileRule
2321
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -30,7 +28,6 @@ import org.junit.runner.RunWith
3028
* start generating a profile directly by implementing [MacrobenchmarkScope.profileBlock].
3129
*/
3230
@RunWith(AndroidJUnit4::class)
33-
@RequiresApi(Build.VERSION_CODES.P)
3431
abstract class BaselineProfileGeneratorScaffold {
3532

3633
@get:Rule
@@ -45,7 +42,8 @@ abstract class BaselineProfileGeneratorScaffold {
4542
fun profileGenerator() {
4643
rule.collect(
4744
packageName = TARGET_PACKAGE,
48-
maxIterations = 10
45+
maxIterations = 15,
46+
stableIterations = 3
4947
) {
5048
profileBlock()
5149
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2024 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+
17+
package com.example.macrobenchmark.baselineprofile
18+
19+
import androidx.benchmark.macro.junit4.BaselineProfileRule
20+
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
21+
import org.junit.Rule
22+
import org.junit.Test
23+
import org.junit.runner.RunWith
24+
25+
/**
26+
* Generates a startup profile.
27+
* See
28+
* [the documentation](https://d.android.com//topic/performance/baselineprofiles/dex-layout-optimizations)
29+
* for details.
30+
*/
31+
@RunWith(AndroidJUnit4ClassRunner::class)
32+
class StartupProfileGenerator {
33+
@get:Rule
34+
val rule = BaselineProfileRule()
35+
36+
@Test
37+
fun profileGenerator() {
38+
rule.collect(
39+
packageName = TARGET_PACKAGE,
40+
maxIterations = 15,
41+
stableIterations = 3,
42+
includeInStartupProfile = true
43+
) {
44+
startActivityAndWait()
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)