-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathgraphql_test.go
65 lines (57 loc) · 1.55 KB
/
graphql_test.go
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
58
59
60
61
62
63
64
65
package graphqlbenchmark
import (
"context"
"testing"
"github.com/graphql-go/graphql"
thunder "github.com/samsarahq/thunder/graphql"
)
func BenchmarkGoGraphQLMaster(b *testing.B) {
// Disable SpecifiedRules
// graphql.SpecifiedRules = []graphql.ValidationRuleFn{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
graphql.Do(graphql.Params{
Schema: graphQLGoSchema,
RequestString: "{hello}",
})
}
}
func BenchmarkPlaylyfeGraphQLMaster(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
context := map[string]interface{}{}
variables := map[string]interface{}{}
playlyfeExecutor.Execute(context, "{hello}", variables, "")
}
}
func BenchmarkGophersGraphQLMaster(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
ctx := context.Background()
variables := map[string]interface{}{}
gopherSchema.Exec(ctx, "{hello}", "", variables)
}
}
func BenchmarkThunderGraphQLMaster(b *testing.B) {
noArguments := func(json interface{}) (interface{}, error) {
return nil, nil
}
var query = &thunder.Object{
Name: "Query",
Fields: make(map[string]*thunder.Field),
}
query.Fields["hello"] = &thunder.Field{
Resolve: func(ctx context.Context, source, args interface{}, selectionSet *thunder.SelectionSet) (interface{}, error) {
return "world", nil
},
Type: &thunder.Scalar{Type: "string"},
ParseArguments: noArguments,
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
q := thunder.MustParse(`{hello}`, map[string]interface{}{})
ctx := context.Background()
e := thunder.Executor{}
e.Execute(ctx, query, nil, q)
}
}