forked from graphql-java/graphql-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntrospectionBenchmark.java
More file actions
57 lines (47 loc) · 1.79 KB
/
Copy pathIntrospectionBenchmark.java
File metadata and controls
57 lines (47 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package benchmark;
import graphql.ExecutionResult;
import graphql.GraphQL;
import graphql.introspection.IntrospectionQuery;
import graphql.schema.GraphQLSchema;
import graphql.schema.idl.SchemaGenerator;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
@State(Scope.Benchmark)
@Warmup(iterations = 2, time = 5)
@Measurement(iterations = 3)
@Fork(2)
public class IntrospectionBenchmark {
@Benchmark
@BenchmarkMode(Mode.AverageTime)
public ExecutionResult benchMarkIntrospectionAvgTime() {
return graphQL.execute(IntrospectionQuery.INTROSPECTION_QUERY);
}
@Benchmark
@BenchmarkMode(Mode.Throughput)
public ExecutionResult benchMarkIntrospectionThroughput() {
return graphQL.execute(IntrospectionQuery.INTROSPECTION_QUERY);
}
private final GraphQL graphQL;
public IntrospectionBenchmark() {
String largeSchema = BenchmarkUtils.loadResource("large-schema-4.graphqls");
GraphQLSchema graphQLSchema = SchemaGenerator.createdMockedSchema(largeSchema);
graphQL = GraphQL.newGraphQL(graphQLSchema)
.build();
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include("benchmark.IntrospectionBenchmark")
.build();
new Runner(opt).run();
}
}