Skip to content

Commit f01306e

Browse files
WIP benchmarking ComposeWorkflow
1 parent 0860065 commit f01306e

File tree

10 files changed

+67
-3
lines changed

10 files changed

+67
-3
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
plugins {
2+
id("com.android.library")
3+
id("org.jetbrains.kotlin.android")
4+
id("android-defaults")
5+
}
6+
7+
// Note: We are not including our defaults from .buildscript as we do not need the base Workflow
8+
// dependencies that those include.
9+
10+
android {
11+
defaultConfig {
12+
// TODO why isn't this taking?
13+
testInstrumentationRunner = "androidx.benchmark.junit4.AndroidBenchmarkRunner"
14+
}
15+
16+
buildTypes {
17+
debug {
18+
// TODO why isn't this available?
19+
// isDebuggable = false
20+
}
21+
}
22+
23+
namespace = "com.squareup.benchmark.composeworkflow.benchmark"
24+
testNamespace = "$namespace.test"
25+
}
26+
27+
dependencies {
28+
androidTestImplementation(project(":workflow-runtime"))
29+
androidTestImplementation(libs.androidx.benchmark)
30+
androidTestImplementation(libs.androidx.test.espresso.core)
31+
androidTestImplementation(libs.androidx.test.junit)
32+
androidTestImplementation(libs.androidx.test.uiautomator)
33+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest>
3+
</manifest>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-dontobfuscate
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.squareup.benchmark.composeworkflow.benchmark
2+
3+
import androidx.benchmark.junit4.BenchmarkRule
4+
import androidx.benchmark.junit4.measureRepeated
5+
import androidx.test.ext.junit.runners.AndroidJUnit4
6+
import org.junit.Rule
7+
import org.junit.Test
8+
import org.junit.runner.RunWith
9+
10+
@RunWith(AndroidJUnit4::class)
11+
class ComposeWorkflowMicroBenchmark {
12+
13+
@get:Rule val benchmarkRule = BenchmarkRule()
14+
15+
@Test fun foo() {
16+
benchmarkRule.measureRepeated {
17+
Thread.sleep(100)
18+
}
19+
}
20+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest>
3+
</manifest>

benchmarks/dungeon-benchmark/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ android {
4545
}
4646

4747
dependencies {
48-
implementation(libs.androidx.macro.benchmark)
48+
implementation(libs.androidx.benchmark.macro)
4949
implementation(libs.androidx.test.espresso.core)
5050
implementation(libs.androidx.test.junit)
5151
implementation(libs.androidx.test.uiautomator)

benchmarks/performance-poetry/complex-benchmark/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ android {
5454
}
5555

5656
dependencies {
57-
implementation(libs.androidx.macro.benchmark)
57+
implementation(libs.androidx.benchmark.macro)
5858
implementation(libs.androidx.test.espresso.core)
5959
implementation(libs.androidx.test.junit)
6060
implementation(libs.androidx.test.uiautomator)

gradle/libs.versions.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ androidx-lifecycle-viewmodel-core = { module = "androidx.lifecycle:lifecycle-vie
163163
androidx-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "androidx-lifecycle" }
164164
androidx-lifecycle-viewmodel-savedstate = { module = "androidx.lifecycle:lifecycle-viewmodel-savedstate", version.ref = "androidx-lifecycle" }
165165

166-
androidx-macro-benchmark = { module = "androidx.benchmark:benchmark-macro-junit4", version.ref = "androidx-benchmark" }
166+
androidx-benchmark = { module = "androidx.benchmark:benchmark-junit4", version.ref = "androidx-benchmark" }
167+
androidx-benchmark-macro = { module = "androidx.benchmark:benchmark-macro-junit4", version.ref = "androidx-benchmark" }
167168

168169
androidx-profileinstaller = { module = "androidx.profileinstaller:profileinstaller", version.ref = "androidx-profileinstaller" }
169170

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ dependencyResolutionManagement {
3434
}
3535

3636
include(
37+
":benchmarks:compose-workflow",
3738
":benchmarks:dungeon-benchmark",
3839
":benchmarks:performance-poetry:complex-benchmark",
3940
":benchmarks:performance-poetry:complex-poetry",

workflow-core/src/commonMain/kotlin/com/squareup/workflow1/compose/ComposeWorkflow.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@file:Suppress("NOTHING_TO_INLINE")
2+
13
package com.squareup.workflow1.compose
24

35
import androidx.compose.runtime.Composable

0 commit comments

Comments
 (0)