MCPcopy
hub / github.com/apache/casbin / BenchmarkRemovePolicyLarge

Function BenchmarkRemovePolicyLarge

management_api_b_test.go:157–174  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

155}
156
157func 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}

Callers

nothing calls this directly

Calls 3

AddPoliciesMethod · 0.95
RemovePolicyMethod · 0.95
NewEnforcerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…