Skip to content

Commit 2777c89

Browse files
authored
Unbreak benchmark (#6641)
1 parent dcb9d9a commit 2777c89

File tree

10 files changed

+45
-31
lines changed

10 files changed

+45
-31
lines changed
Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
plugins {
2-
`embedded-kotlin`
3-
`java-gradle-plugin`
2+
alias(libs.plugins.kotlin.jvm)
3+
alias(libs.plugins.compat.patrouille)
44
}
55

6-
group = "com.apollographql.apollo.benchmark"
6+
group = "benchmark"
7+
8+
compatPatrouille {
9+
java(17)
10+
kotlin(embeddedKotlinVersion)
11+
}
712

813
dependencies {
914
compileOnly(gradleApi())
@@ -13,13 +18,3 @@ dependencies {
1318
implementation(libs.android.plugin)
1419
implementation(libs.benchmark.gradle.plugin)
1520
}
16-
17-
18-
gradlePlugin {
19-
plugins {
20-
register("apollo.benchmark") {
21-
id = "apollo.benchmark"
22-
implementationClass = "BenchmarkPlugin"
23-
}
24-
}
25-
}

benchmark/build-logic/gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../gradle

benchmark/build-logic/gradlew

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../gradlew

benchmark/build.gradle.kts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
plugins {
2-
id("apollo.benchmark").apply(false)
3-
alias(libs.plugins.apollo).apply(false)
2+
id("base")
43
}
4+
5+
buildscript {
6+
dependencies {
7+
classpath("com.apollographql.apollo:apollo-gradle-plugin")
8+
classpath("benchmark:build-logic")
9+
}
10+
}

benchmark/microbenchmark/src/androidTest/java/com/apollographql/apollo/benchmark/ApolloStoreIncubatingTests.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.apollographql.cache.normalized.CacheManager
1212
import com.apollographql.cache.normalized.memory.MemoryCacheFactory
1313
import com.apollographql.cache.normalized.api.NormalizedCacheFactory
1414
import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory
15+
import kotlinx.coroutines.runBlocking
1516
import org.junit.Assert
1617
import org.junit.Rule
1718
import org.junit.Test
@@ -50,9 +51,11 @@ class ApolloStoreIncubatingTests {
5051
threadPool.submit {
5152
// Let each thread execute a few writes/reads
5253
repeat(WORK_LOAD) {
53-
apolloStore.writeOperation(query, data)
54-
val data2 = apolloStore.readOperation(query).data
55-
Assert.assertEquals(data, data2)
54+
runBlocking {
55+
apolloStore.writeOperation(query, data)
56+
val data2 = apolloStore.readOperation(query).data
57+
Assert.assertEquals(data, data2)
58+
}
5659
}
5760
}
5861
}

benchmark/microbenchmark/src/androidTest/java/com/apollographql/apollo/benchmark/CacheIncubatingTests.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ class CacheIncubatingTests {
7373
registerCacheSize("CacheIncubatingTests", testName, dbFile.length())
7474
}
7575
benchmarkRule.measureRepeated {
76-
val data2 = cacheManager.readOperation(query).data!!
77-
check(data2)
76+
runBlocking {
77+
val data2 = cacheManager.readOperation(query).data!!
78+
check(data2)
79+
}
7880
}
7981
}
8082
}

benchmark/microbenchmark/src/androidTest/java/com/apollographql/apollo/benchmark/FakeData.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import com.apollographql.apollo.conferences.fragment.SpeakerDetails
88
import com.apollographql.cache.normalized.CacheManager
99
import com.apollographql.cache.normalized.api.ApolloCacheHeaders
1010
import com.apollographql.cache.normalized.api.CacheHeaders
11+
import kotlinx.coroutines.runBlocking
1112

1213
const val SESSION_COUNT = 100
1314

14-
fun primeCache(cacheManager: CacheManager) {
15+
fun primeCache(cacheManager: CacheManager) = runBlocking {
1516
val query1 = GetConferenceDataQuery(Optional.present(SESSION_COUNT))
1617
var data: GetConferenceDataQuery.Data = GetConferenceDataQuery.Data(
1718
sessions = createSessions(0),

benchmark/microbenchmark/src/androidTest/java/com/apollographql/apollo/benchmark/GarbageCollectTests.kt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import com.apollographql.cache.normalized.api.SchemaCoordinatesMaxAgeProvider
1111
import com.apollographql.cache.normalized.garbageCollect
1212
import com.apollographql.cache.normalized.memory.MemoryCacheFactory
1313
import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory
14+
import kotlinx.coroutines.runBlocking
1415
import org.junit.Rule
1516
import org.junit.Test
1617
import kotlin.time.Duration.Companion.days
@@ -27,8 +28,10 @@ class GarbageCollectTests {
2728
cacheManager = CacheManager(MemoryCacheFactory())
2829
primeCache(cacheManager)
2930
}
30-
cacheManager.accessCache {
31-
it.garbageCollect(maxAgeProvider)
31+
runBlocking {
32+
cacheManager.accessCache {
33+
it.garbageCollect(maxAgeProvider)
34+
}
3235
}
3336
}
3437
}
@@ -42,8 +45,10 @@ class GarbageCollectTests {
4245
cacheManager = CacheManager(SqlNormalizedCacheFactory(dbName))
4346
primeCache(cacheManager)
4447
}
45-
cacheManager.accessCache {
46-
it.garbageCollect(maxAgeProvider)
48+
runBlocking {
49+
cacheManager.accessCache {
50+
it.garbageCollect(maxAgeProvider)
51+
}
4752
}
4853
}
4954
}
@@ -57,8 +62,10 @@ class GarbageCollectTests {
5762
cacheManager = CacheManager(MemoryCacheFactory().chain(SqlNormalizedCacheFactory(dbName)))
5863
primeCache(cacheManager)
5964
}
60-
cacheManager.accessCache {
61-
it.garbageCollect(maxAgeProvider)
65+
runBlocking {
66+
cacheManager.accessCache {
67+
it.garbageCollect(maxAgeProvider)
68+
}
6269
}
6370
}
6471
}

benchmark/settings.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
pluginManagement {
2-
includeBuild("build-logic")
3-
}
41
plugins {
52
id("com.gradle.develocity") version "4.1" // sync with libraries.toml
63
id("com.gradle.common-custom-user-data-gradle-plugin") version "2.3"
@@ -28,4 +25,5 @@ listOf(pluginManagement.repositories, dependencyResolutionManagement.repositorie
2825
}
2926
}
3027

28+
includeBuild("build-logic")
3129
includeBuild("../")

gradle/libraries.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ androidx-sqlite = "2.3.1"
1717
# This is used by the gradle integration tests to get the artifacts locally
1818
apollo = "5.0.0-alpha.2-SNAPSHOT"
1919
apollo-execution = "0.1.0"
20-
apollo-normalizedcache-incubating = "1.0.0-alpha.3"
20+
apollo-normalizedcache-incubating = "1.0.0-alpha.4"
2121
# Used by the apollo-tooling project which uses a published version of Apollo
2222
apollo-published = "4.0.1"
2323
atomicfu = "0.26.0"

0 commit comments

Comments
 (0)