Skip to content

Commit 9f509f3

Browse files
andimarekclaude
andcommitted
Benchmark introspection against multiple large schemas
Use JMH @param to run IntrospectionBenchmark against 5 schemas of increasing size (medium to very large) instead of only large-schema-4. This helps characterize introspection performance scaling. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f7a2377 commit 9f509f3

File tree

1 file changed

+34
-10
lines changed

1 file changed

+34
-10
lines changed

src/jmh/java/benchmark/IntrospectionBenchmark.java

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,58 @@
88
import org.openjdk.jmh.annotations.Benchmark;
99
import org.openjdk.jmh.annotations.BenchmarkMode;
1010
import org.openjdk.jmh.annotations.Fork;
11+
import org.openjdk.jmh.annotations.Level;
1112
import org.openjdk.jmh.annotations.Measurement;
1213
import org.openjdk.jmh.annotations.Mode;
14+
import org.openjdk.jmh.annotations.OutputTimeUnit;
15+
import org.openjdk.jmh.annotations.Param;
1316
import org.openjdk.jmh.annotations.Scope;
17+
import org.openjdk.jmh.annotations.Setup;
1418
import org.openjdk.jmh.annotations.State;
1519
import org.openjdk.jmh.annotations.Warmup;
1620
import org.openjdk.jmh.runner.Runner;
1721
import org.openjdk.jmh.runner.RunnerException;
1822
import org.openjdk.jmh.runner.options.Options;
1923
import org.openjdk.jmh.runner.options.OptionsBuilder;
2024

25+
import java.util.concurrent.TimeUnit;
26+
2127
@State(Scope.Benchmark)
2228
@Warmup(iterations = 2, time = 5)
2329
@Measurement(iterations = 3)
2430
@Fork(2)
2531
public class IntrospectionBenchmark {
2632

33+
@Param({
34+
"large-schema-2.graphqls",
35+
"large-schema-3.graphqls",
36+
"large-schema-4.graphqls",
37+
"large-schema-5.graphqls",
38+
"large-schema-federated-1.graphqls"
39+
})
40+
String schemaFile;
41+
42+
private GraphQL graphQL;
43+
44+
@Setup(Level.Trial)
45+
public void setup() {
46+
String schema = loadSchema(schemaFile);
47+
GraphQLSchema graphQLSchema = SchemaGenerator.createdMockedSchema(schema);
48+
graphQL = GraphQL.newGraphQL(graphQLSchema).build();
49+
}
50+
51+
private static String loadSchema(String schemaFile) {
52+
if (schemaFile.equals("large-schema-5.graphqls")) {
53+
// This schema is split across two files due to its size (11.3 MB)
54+
return BenchmarkUtils.loadResource("large-schema-5.graphqls.part1")
55+
+ BenchmarkUtils.loadResource("large-schema-5.graphqls.part2");
56+
}
57+
return BenchmarkUtils.loadResource(schemaFile);
58+
}
59+
2760
@Benchmark
2861
@BenchmarkMode(Mode.AverageTime)
62+
@OutputTimeUnit(TimeUnit.MILLISECONDS)
2963
public ExecutionResult benchMarkIntrospectionAvgTime() {
3064
return graphQL.execute(IntrospectionQuery.INTROSPECTION_QUERY);
3165
}
@@ -36,16 +70,6 @@ public ExecutionResult benchMarkIntrospectionThroughput() {
3670
return graphQL.execute(IntrospectionQuery.INTROSPECTION_QUERY);
3771
}
3872

39-
private final GraphQL graphQL;
40-
41-
42-
public IntrospectionBenchmark() {
43-
String largeSchema = BenchmarkUtils.loadResource("large-schema-4.graphqls");
44-
GraphQLSchema graphQLSchema = SchemaGenerator.createdMockedSchema(largeSchema);
45-
graphQL = GraphQL.newGraphQL(graphQLSchema)
46-
.build();
47-
}
48-
4973
public static void main(String[] args) throws RunnerException {
5074
Options opt = new OptionsBuilder()
5175
.include("benchmark.IntrospectionBenchmark")

0 commit comments

Comments
 (0)