(b *testing.B)
| 97 | } |
| 98 | |
| 99 | func BenchmarkCachedRBACModelLarge(b *testing.B) { |
| 100 | e, _ := NewCachedEnforcer("examples/rbac_model.conf") |
| 101 | |
| 102 | // 10000 roles, 1000 resources. |
| 103 | pPolicies := make([][]string, 0) |
| 104 | for i := 0; i < 10000; i++ { |
| 105 | pPolicies = append(pPolicies, []string{fmt.Sprintf("group%d", i), fmt.Sprintf("data%d", i/10), "read"}) |
| 106 | } |
| 107 | _, err := e.AddPolicies(pPolicies) |
| 108 | if err != nil { |
| 109 | b.Fatal(err) |
| 110 | } |
| 111 | |
| 112 | // 100000 users. |
| 113 | gPolicies := make([][]string, 0) |
| 114 | for i := 0; i < 100000; i++ { |
| 115 | gPolicies = append(gPolicies, []string{fmt.Sprintf("user%d", i), fmt.Sprintf("group%d", i/10)}) |
| 116 | } |
| 117 | _, err = e.AddGroupingPolicies(gPolicies) |
| 118 | if err != nil { |
| 119 | b.Fatal(err) |
| 120 | } |
| 121 | |
| 122 | b.ResetTimer() |
| 123 | for i := 0; i < b.N; i++ { |
| 124 | _, _ = e.Enforce("user50001", "data1500", "read") |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | func BenchmarkCachedRBACModelWithResourceRoles(b *testing.B) { |
| 129 | e, _ := NewCachedEnforcer("examples/rbac_with_resource_roles_model.conf", "examples/rbac_with_resource_roles_policy.csv") |
nothing calls this directly
no test coverage detected
searching dependent graphs…