Running the Benchmark: Command: go test -bench=. -benchtime=60s go test -bench=. -benchtime=60s goos: linux goarch: amd64 pkg: github.com/dgraph-io/dgraph/v25/graphql/e2e/auth/bench Auth BenchmarkNestedQuery-8 88 815315761 ns/op BenchmarkOneLevelQuery-8 4357
(b *testing.B)
| 177 | //} |
| 178 | |
| 179 | func BenchmarkNestedQuery(b *testing.B) { |
| 180 | schemaFile := "schema_auth.graphql" |
| 181 | schema, err := os.ReadFile(schemaFile) |
| 182 | require.NoError(b, err) |
| 183 | |
| 184 | metaInfo := getAuthMeta(string(schema)) |
| 185 | metaInfo.AuthVars = map[string]interface{}{ |
| 186 | "Role": "ADMIN", |
| 187 | "Dish": "Dish", |
| 188 | "RName": "Restaurant", |
| 189 | "RCurr": "$", |
| 190 | } |
| 191 | |
| 192 | query := ` |
| 193 | query { |
| 194 | queryCuisine (first: 100) { |
| 195 | id |
| 196 | name |
| 197 | restaurants (first: 100) { |
| 198 | id |
| 199 | name |
| 200 | dishes (first: 100) { |
| 201 | id |
| 202 | name |
| 203 | } |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | ` |
| 208 | |
| 209 | getUserParams := &common.GraphQLParams{ |
| 210 | Headers: getJWT(b, metaInfo), |
| 211 | Query: query, |
| 212 | } |
| 213 | |
| 214 | for i := 0; i < b.N; i++ { |
| 215 | gqlResponse := getUserParams.ExecuteAsPost(b, graphqlURL) |
| 216 | require.Nilf(b, gqlResponse.Errors, "%+v", gqlResponse.Errors) |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | func BenchmarkOneLevelQuery(b *testing.B) { |
| 221 | schemaFile := "schema_auth.graphql" |
nothing calls this directly
no test coverage detected