(b *testing.B)
| 136 | } |
| 137 | |
| 138 | func BenchmarkRemovePolicyMedium(b *testing.B) { |
| 139 | e, _ := NewEnforcer("examples/basic_model.conf") |
| 140 | |
| 141 | // 1000 roles, 100 resources. |
| 142 | pPolicies := make([][]string, 0) |
| 143 | for i := 0; i < 1000; i++ { |
| 144 | pPolicies = append(pPolicies, []string{fmt.Sprintf("user%d", i), fmt.Sprintf("data%d", i/10), "read"}) |
| 145 | } |
| 146 | _, err := e.AddPolicies(pPolicies) |
| 147 | if err != nil { |
| 148 | b.Fatal(err) |
| 149 | } |
| 150 | |
| 151 | b.ResetTimer() |
| 152 | for i := 0; i < b.N; i++ { |
| 153 | _, _ = e.RemovePolicy(fmt.Sprintf("user%d", rand.Intn(1000)), fmt.Sprintf("data%d", rand.Intn(1000)/10), "read") |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | func BenchmarkRemovePolicyLarge(b *testing.B) { |
| 158 | e, _ := NewEnforcer("examples/basic_model.conf") |
nothing calls this directly
no test coverage detected
searching dependent graphs…