(b *testing.B)
| 496 | } |
| 497 | |
| 498 | func BenchmarkMutation(b *testing.B) { |
| 499 | schemaFile := "schema_auth.graphql" |
| 500 | schema, err := os.ReadFile(schemaFile) |
| 501 | require.NoError(b, err) |
| 502 | |
| 503 | metaInfo := getAuthMeta(string(schema)) |
| 504 | metaInfo.AuthVars = map[string]interface{}{ |
| 505 | "Role": "ADMIN", |
| 506 | "USERNAME": "$", |
| 507 | } |
| 508 | |
| 509 | owners := generateOwnerRestaurant(100) |
| 510 | owners.add(b, metaInfo) |
| 511 | |
| 512 | query := ` |
| 513 | query { |
| 514 | queryRestaurant (first: 300000) { |
| 515 | id |
| 516 | name |
| 517 | owner { |
| 518 | username |
| 519 | } |
| 520 | } |
| 521 | } |
| 522 | ` |
| 523 | |
| 524 | getUserParams := &common.GraphQLParams{ |
| 525 | Headers: getJWT(b, metaInfo), |
| 526 | Query: query, |
| 527 | } |
| 528 | |
| 529 | var totalTime time.Duration |
| 530 | for i := 0; i < b.N; i++ { |
| 531 | before := time.Now() |
| 532 | gqlResponse := getUserParams.ExecuteAsPost(b, graphqlURL) |
| 533 | require.Nilf(b, gqlResponse.Errors, "%+v", gqlResponse.Errors) |
| 534 | reqTime := time.Since(before) |
| 535 | totalTime += reqTime |
| 536 | if i%10 == 0 { |
| 537 | avgTime := int64(totalTime) / (int64(i + 1)) |
| 538 | fmt.Printf("Avg Time: %d Time: %d \n", avgTime, reqTime) |
| 539 | } |
| 540 | // Stopping the timer as we don't want to include the clean up time in benchmark result. |
| 541 | b.StopTimer() |
| 542 | clearAll(b, metaInfo) |
| 543 | } |
| 544 | } |
nothing calls this directly
no test coverage detected