MCPcopy
hub / github.com/dgraph-io/dgraph / BenchmarkMultiLevelMutation

Function BenchmarkMultiLevelMutation

graphql/bench/auth_test.go:423–451  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

421}
422
423func BenchmarkMultiLevelMutation(b *testing.B) {
424 schemaFile := "schema_auth.graphql"
425 schema, err := os.ReadFile(schemaFile)
426 require.NoError(b, err)
427
428 metaInfo := getAuthMeta(string(schema))
429 metaInfo.AuthVars = map[string]interface{}{
430 "Role": "ADMIN",
431 "Dish": "Dish",
432 "RName": "Restaurant",
433 "RCurr": "$",
434 }
435
436 restaurants := generateMultiLevelMutationData(20)
437 var totalTime time.Duration
438 for i := 0; i < b.N; i++ {
439 before := time.Now()
440 restaurants.add(b, metaInfo)
441 reqTime := time.Since(before)
442 totalTime += reqTime
443 if i%10 == 0 {
444 avgTime := int64(totalTime) / int64(i+1)
445 fmt.Printf("Avg Time: %d Time: %d \n", avgTime, reqTime)
446 }
447 // Stopping the timer as we don't want to include the clean up time in benchmark result.
448 b.StopTimer()
449 clearAll(b, metaInfo)
450 }
451}
452
453// generateOwnerRestaurant generates `items` number of `Owner`. Each `Owner` having
454// `items` number of `Restaurant`.

Callers

nothing calls this directly

Calls 4

getAuthMetaFunction · 0.85
clearAllFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected