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

Function BenchmarkRemovePolicyMedium

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

Source from the content-addressed store, hash-verified

136}
137
138func 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
157func BenchmarkRemovePolicyLarge(b *testing.B) {
158 e, _ := NewEnforcer("examples/basic_model.conf")

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…