Skip to content

Commit 90dee30

Browse files
committed
Add performance benchmarks for DataFetchingFieldSelectionSet.getImmediateFields
1 parent 55062e4 commit 90dee30

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/test/java/performance/DFSelectionSetPerformance.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,32 @@ public void benchMarkThroughput(MyState myState, Blackhole blackhole) {
6767
blackhole.consume(fields);
6868
}
6969

70+
@Benchmark
71+
@BenchmarkMode(Mode.AverageTime)
72+
@OutputTimeUnit(TimeUnit.MILLISECONDS)
73+
public void benchMarkAvgTime_getImmediateFields(MyState myState, Blackhole blackhole) {
74+
List<SelectedField> fields = getImmediateFields(myState);
75+
blackhole.consume(fields);
76+
}
77+
78+
@Benchmark
79+
@BenchmarkMode(Mode.Throughput)
80+
@OutputTimeUnit(TimeUnit.MILLISECONDS)
81+
public void benchMarkThroughput_getImmediateFields(MyState myState, Blackhole blackhole) {
82+
List<SelectedField> fields = getImmediateFields(myState);
83+
blackhole.consume(fields);
84+
}
85+
7086
private List<SelectedField> getSelectedFields(MyState myState) {
7187
DataFetchingFieldSelectionSet dataFetchingFieldSelectionSet = DataFetchingFieldSelectionSetImpl.newCollector(myState.schema, myState.outputFieldType, () -> myState.normalisedField);
7288
return dataFetchingFieldSelectionSet.getFields("wontBeFound");
7389
}
7490

91+
private List<SelectedField> getImmediateFields(MyState myState) {
92+
DataFetchingFieldSelectionSet dataFetchingFieldSelectionSet = DataFetchingFieldSelectionSetImpl.newCollector(myState.schema, myState.outputFieldType, () -> myState.normalisedField);
93+
return dataFetchingFieldSelectionSet.getImmediateFields();
94+
}
95+
7596
public static void mainX(String[] args) throws InterruptedException {
7697
MyState myState = new MyState();
7798
myState.setup();

0 commit comments

Comments
 (0)