Skip to content

Commit 6b22e9f

Browse files
author
Samuel Vazquez
committed
feat: add separate benchmark tasks
1 parent 6728a8f commit 6b22e9f

File tree

7 files changed

+29
-20
lines changed

7 files changed

+29
-20
lines changed

servers/graphql-kotlin-server/build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ kotlin.sourceSets.getByName("benchmarks") {
3131
}
3232

3333
benchmark {
34+
configurations {
35+
register("graphQLRequest") {
36+
include("com.expediagroup.graphql.server.GraphQLServerRequest*")
37+
}
38+
register("graphQLResponse") {
39+
include("com.expediagroup.graphql.server.GraphQLServerResponse*")
40+
}
41+
}
3442
targets {
3543
register("benchmarks") {
3644
this as JvmBenchmarkTarget
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ import java.util.concurrent.TimeUnit
3333

3434
@State(Scope.Benchmark)
3535
@Fork(value = 5, jvmArgsAppend = ["--add-modules=jdk.incubator.vector", "-Dfastjson2.readerVector=true"])
36-
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
37-
@Measurement(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)
38-
open class GraphQLServerBatchRequestDeserializationBenchmark {
36+
@Warmup(iterations = 1, time = 1, timeUnit = TimeUnit.SECONDS)
37+
@Measurement(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS)
38+
open class GraphQLServerRequestBatchDeserializationBenchmark {
3939
private val mapper = jacksonObjectMapper()
4040
private lateinit var request: String
4141
private lateinit var batchRequest: String

servers/graphql-kotlin-server/src/benchmarks/kotlin/GraphQLServerRequestDeserializationBenchmark.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ import java.util.concurrent.TimeUnit
3333

3434
@State(Scope.Benchmark)
3535
@Fork(value = 5, jvmArgsAppend = ["--add-modules=jdk.incubator.vector", "-Dfastjson2.readerVector=true"])
36-
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
37-
@Measurement(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)
36+
@Warmup(iterations = 1, time = 1, timeUnit = TimeUnit.SECONDS)
37+
@Measurement(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS)
3838
open class GraphQLServerRequestDeserializationBenchmark {
3939
private val mapper = jacksonObjectMapper()
4040
private lateinit var request: String
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ import java.util.concurrent.TimeUnit
3333

3434
@State(Scope.Benchmark)
3535
@Fork(value = 5, jvmArgsAppend = ["--add-modules=jdk.incubator.vector", "-Dfastjson2.readerVector=true"])
36-
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
37-
@Measurement(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)
38-
open class GraphQLServerBatchResponseSerializationBenchmark {
36+
@Warmup(iterations = 1, time = 1, timeUnit = TimeUnit.SECONDS)
37+
@Measurement(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS)
38+
open class GraphQLServerResponseBatchSerializationBenchmark {
3939
private val mapper = jacksonObjectMapper()
4040
private lateinit var batchResponse: GraphQLBatchResponse
4141

servers/graphql-kotlin-server/src/benchmarks/kotlin/GraphQLServerResponseSerializationBenchmark.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package com.expediagroup.graphql.server
1818

1919
import com.alibaba.fastjson2.JSON
2020
import com.alibaba.fastjson2.JSONWriter
21-
import com.expediagroup.graphql.server.testtypes.GraphQLResponse
21+
import com.expediagroup.graphql.server.types.GraphQLResponse
2222
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
2323
import com.fasterxml.jackson.module.kotlin.readValue
2424
import org.openjdk.jmh.annotations.Benchmark
@@ -32,11 +32,11 @@ import java.util.concurrent.TimeUnit
3232

3333
@State(Scope.Benchmark)
3434
@Fork(value = 5, jvmArgsAppend = ["--add-modules=jdk.incubator.vector", "-Dfastjson2.readerVector=true"])
35-
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
36-
@Measurement(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)
35+
@Warmup(iterations = 1, time = 1, timeUnit = TimeUnit.SECONDS)
36+
@Measurement(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS)
3737
open class GraphQLServerResponseSerializationBenchmark {
3838
private val mapper = jacksonObjectMapper()
39-
private lateinit var response: GraphQLResponse
39+
private lateinit var response: GraphQLResponse<Map<String, Any?>>
4040

4141
@Setup
4242
fun setUp() {

servers/graphql-kotlin-spring-server/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ tasks {
2727
limit {
2828
counter = "INSTRUCTION"
2929
value = "COVEREDRATIO"
30-
minimum = "0.87".toBigDecimal()
30+
minimum = "0.86".toBigDecimal()
3131
}
3232
limit {
3333
counter = "BRANCH"

servers/graphql-kotlin-spring-server/src/test/kotlin/com/expediagroup/graphql/server/spring/SubscriptionConfigurationTest.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 Expedia, Inc
2+
* Copyright 2024 Expedia, Inc
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,14 +29,14 @@ import com.fasterxml.jackson.databind.ObjectMapper
2929
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
3030
import graphql.GraphQL
3131
import graphql.schema.GraphQLSchema
32+
import io.mockk.every
3233
import io.mockk.mockk
3334
import org.assertj.core.api.Assertions.assertThat
3435
import org.junit.jupiter.api.Test
3536
import org.springframework.boot.autoconfigure.AutoConfigurations
3637
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner
3738
import org.springframework.context.annotation.Bean
3839
import org.springframework.context.annotation.Configuration
39-
import org.springframework.web.reactive.HandlerMapping
4040
import org.springframework.web.reactive.socket.server.support.WebSocketHandlerAdapter
4141
import reactor.core.publisher.Flux
4242
import java.time.Duration
@@ -73,7 +73,7 @@ class SubscriptionConfigurationTest {
7373

7474
assertThat(ctx).hasSingleBean(SubscriptionWebSocketHandler::class.java)
7575
assertThat(ctx).hasSingleBean(WebSocketHandlerAdapter::class.java)
76-
assertThat(ctx).hasSingleBean(HandlerMapping::class.java)
76+
assertThat(ctx).hasBean("subscriptionHandlerMapping")
7777
}
7878
}
7979

@@ -102,10 +102,9 @@ class SubscriptionConfigurationTest {
102102

103103
assertThat(ctx).hasSingleBean(ApolloSubscriptionWebSocketHandler::class.java)
104104

105-
assertThat(ctx).hasSingleBean(WebSocketHandlerAdapter::class.java)
106-
assertThat(ctx).getBean(WebSocketHandlerAdapter::class.java)
105+
assertThat(ctx).hasBean("webSocketHandlerAdapter")
106+
assertThat(ctx).getBean("webSocketHandlerAdapter")
107107
.isSameAs(customConfiguration.webSocketHandlerAdapter())
108-
assertThat(ctx).hasSingleBean(HandlerMapping::class.java)
109108
}
110109
}
111110

@@ -146,7 +145,9 @@ class SubscriptionConfigurationTest {
146145
@Bean
147146
fun subscription(): Subscription = SimpleSubscription()
148147
@Bean
149-
fun webSocketHandlerAdapter(): WebSocketHandlerAdapter = mockk()
148+
fun webSocketHandlerAdapter(): WebSocketHandlerAdapter = mockk {
149+
every { order } returns 1
150+
}
150151
}
151152

152153
// GraphQL spec requires at least single query to be present as Query type is needed to run introspection queries

0 commit comments

Comments
 (0)