(b *testing.B)
| 190 | } |
| 191 | |
| 192 | func BenchmarkCachedRBACModelMediumParallel(b *testing.B) { |
| 193 | e, _ := NewCachedEnforcer("examples/rbac_model.conf") |
| 194 | |
| 195 | // 10000 roles, 1000 resources. |
| 196 | pPolicies := make([][]string, 0) |
| 197 | for i := 0; i < 10000; i++ { |
| 198 | pPolicies = append(pPolicies, []string{fmt.Sprintf("group%d", i), fmt.Sprintf("data%d", i/10), "read"}) |
| 199 | } |
| 200 | _, err := e.AddPolicies(pPolicies) |
| 201 | if err != nil { |
| 202 | b.Fatal(err) |
| 203 | } |
| 204 | |
| 205 | // 100000 users. |
| 206 | gPolicies := make([][]string, 0) |
| 207 | for i := 0; i < 100000; i++ { |
| 208 | gPolicies = append(gPolicies, []string{fmt.Sprintf("user%d", i), fmt.Sprintf("group%d", i/10)}) |
| 209 | } |
| 210 | _, err = e.AddGroupingPolicies(gPolicies) |
| 211 | if err != nil { |
| 212 | b.Fatal(err) |
| 213 | } |
| 214 | |
| 215 | b.ResetTimer() |
| 216 | b.RunParallel(func(pb *testing.PB) { |
| 217 | for pb.Next() { |
| 218 | _, _ = e.Enforce("user5001", "data150", "read") |
| 219 | } |
| 220 | }) |
| 221 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…