forked from graphql-java/graphql-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddError.java
More file actions
38 lines (32 loc) · 1.16 KB
/
AddError.java
File metadata and controls
38 lines (32 loc) · 1.16 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
package benchmark;
import graphql.execution.ExecutionContext;
import graphql.execution.ExecutionContextBuilder;
import graphql.execution.ExecutionId;
import graphql.execution.ResultPath;
import graphql.schema.idl.errors.SchemaMissingError;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
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 java.util.Collections;
@State(Scope.Benchmark)
public class AddError {
private ExecutionContext context = new ExecutionContextBuilder()
.executionId(ExecutionId.generate())
.build();
private volatile int x = 0;
38B4
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
@Warmup(iterations = 1, batchSize = 50000)
@Measurement(iterations = 1, batchSize = 5000)
public ExecutionContext benchMarkAddError() {
context.addError(
new SchemaMissingError(),
ResultPath.fromList(Collections.singletonList(x++))
);
return context;
}
}