Skip to content

Commit 6b3c61f

Browse files
committed
add printer.Print benchmark
1 parent 4ebf270 commit 6b3c61f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

language/printer/printer_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,27 @@ func TestPrinter_CorrectlyPrintsStringArgumentsWithProperQuoting(t *testing.T) {
200200
t.Fatalf("Unexpected result, Diff: %v", testutil.Diff(expected, results))
201201
}
202202
}
203+
204+
func BenchmarkPrint(b *testing.B) {
205+
q, err := ioutil.ReadFile("../../kitchen-sink.graphql")
206+
if err != nil {
207+
b.Fatalf("unable to load kitchen-sink.graphql")
208+
}
209+
210+
query := string(q)
211+
212+
astDoc, err := parser.Parse(parser.ParseParams{
213+
Source: query,
214+
Options: parser.ParseOptions{
215+
NoLocation: true,
216+
},
217+
})
218+
if err != nil {
219+
b.Fatalf("Parse failed: %v", err)
220+
}
221+
222+
b.ResetTimer()
223+
for i := 0; i < b.N; i++ {
224+
_ = printer.Print(astDoc)
225+
}
226+
}

0 commit comments

Comments
 (0)