(b *testing.B)
| 155 | } |
| 156 | |
| 157 | func BenchmarkRemovePolicyLarge(b *testing.B) { |
| 158 | e, _ := NewEnforcer("examples/basic_model.conf") |
| 159 | |
| 160 | // 10000 roles, 1000 resources. |
| 161 | pPolicies := make([][]string, 0) |
| 162 | for i := 0; i < 10000; i++ { |
| 163 | pPolicies = append(pPolicies, []string{fmt.Sprintf("user%d", i), fmt.Sprintf("data%d", i/10), "read"}) |
| 164 | } |
| 165 | _, err := e.AddPolicies(pPolicies) |
| 166 | if err != nil { |
| 167 | b.Fatal(err) |
| 168 | } |
| 169 | |
| 170 | b.ResetTimer() |
| 171 | for i := 0; i < b.N; i++ { |
| 172 | _, _ = e.RemovePolicy(fmt.Sprintf("user%d", rand.Intn(10000)), fmt.Sprintf("data%d", rand.Intn(10000)/10), "read") |
| 173 | } |
| 174 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…