(b *testing.B)
| 150 | } |
| 151 | |
| 152 | func BenchmarkRBACModelMedium(b *testing.B) { |
| 153 | e, _ := NewEnforcer("examples/rbac_model.conf") |
| 154 | |
| 155 | // 1000 roles, 100 resources. |
| 156 | pPolicies := make([][]string, 0) |
| 157 | for i := 0; i < 1000; i++ { |
| 158 | pPolicies = append(pPolicies, []string{fmt.Sprintf("group%d", i), fmt.Sprintf("data%d", i/10), "read"}) |
| 159 | } |
| 160 | |
| 161 | _, err := e.AddPolicies(pPolicies) |
| 162 | if err != nil { |
| 163 | b.Fatal(err) |
| 164 | } |
| 165 | |
| 166 | // 10000 users. |
| 167 | gPolicies := make([][]string, 0) |
| 168 | for i := 0; i < 10000; i++ { |
| 169 | gPolicies = append(gPolicies, []string{fmt.Sprintf("user%d", i), fmt.Sprintf("group%d", i/10)}) |
| 170 | } |
| 171 | |
| 172 | _, err = e.AddGroupingPolicies(gPolicies) |
| 173 | if err != nil { |
| 174 | b.Fatal(err) |
| 175 | } |
| 176 | |
| 177 | b.ResetTimer() |
| 178 | for i := 0; i < b.N; i++ { |
| 179 | _, _ = e.Enforce("user5001", "data99", "read") |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | func BenchmarkRBACModelLarge(b *testing.B) { |
| 184 | e, _ := NewEnforcer("examples/rbac_model.conf") |
nothing calls this directly
no test coverage detected
searching dependent graphs…