(b *testing.B)
| 67 | } |
| 68 | |
| 69 | func BenchmarkCachedRBACModelMedium(b *testing.B) { |
| 70 | e, _ := NewCachedEnforcer("examples/rbac_model.conf") |
| 71 | // 1000 roles, 100 resources. |
| 72 | pPolicies := make([][]string, 0) |
| 73 | for i := 0; i < 1000; i++ { |
| 74 | pPolicies = append(pPolicies, []string{fmt.Sprintf("group%d", i), fmt.Sprintf("data%d", i/10), "read"}) |
| 75 | } |
| 76 | |
| 77 | _, err := e.AddPolicies(pPolicies) |
| 78 | if err != nil { |
| 79 | b.Fatal(err) |
| 80 | } |
| 81 | |
| 82 | // 10000 users. |
| 83 | gPolicies := make([][]string, 0) |
| 84 | for i := 0; i < 10000; i++ { |
| 85 | gPolicies = append(gPolicies, []string{fmt.Sprintf("user%d", i), fmt.Sprintf("group%d", i/10)}) |
| 86 | } |
| 87 | |
| 88 | _, err = e.AddGroupingPolicies(gPolicies) |
| 89 | if err != nil { |
| 90 | b.Fatal(err) |
| 91 | } |
| 92 | |
| 93 | b.ResetTimer() |
| 94 | for i := 0; i < b.N; i++ { |
| 95 | _, _ = e.Enforce("user5001", "data150", "read") |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | func BenchmarkCachedRBACModelLarge(b *testing.B) { |
| 100 | e, _ := NewCachedEnforcer("examples/rbac_model.conf") |
nothing calls this directly
no test coverage detected
searching dependent graphs…