(b *testing.B)
| 181 | } |
| 182 | |
| 183 | func BenchmarkRBACModelLarge(b *testing.B) { |
| 184 | e, _ := NewEnforcer("examples/rbac_model.conf") |
| 185 | |
| 186 | // 10000 roles, 1000 resources. |
| 187 | pPolicies := make([][]string, 0) |
| 188 | for i := 0; i < 10000; i++ { |
| 189 | pPolicies = append(pPolicies, []string{fmt.Sprintf("group%d", i), fmt.Sprintf("data%d", i/10), "read"}) |
| 190 | } |
| 191 | |
| 192 | _, err := e.AddPolicies(pPolicies) |
| 193 | if err != nil { |
| 194 | b.Fatal(err) |
| 195 | } |
| 196 | |
| 197 | // 100000 users. |
| 198 | gPolicies := make([][]string, 0) |
| 199 | for i := 0; i < 100000; i++ { |
| 200 | gPolicies = append(gPolicies, []string{fmt.Sprintf("user%d", i), fmt.Sprintf("group%d", i/10)}) |
| 201 | } |
| 202 | |
| 203 | _, err = e.AddGroupingPolicies(gPolicies) |
| 204 | if err != nil { |
| 205 | b.Fatal(err) |
| 206 | } |
| 207 | |
| 208 | b.ResetTimer() |
| 209 | for i := 0; i < b.N; i++ { |
| 210 | _, _ = e.Enforce("user50001", "data999", "read") |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | func BenchmarkRBACModelWithResourceRoles(b *testing.B) { |
| 215 | e, _ := NewEnforcer("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…