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

Function BenchmarkABACRuleModel

model_b_test.go:242–254  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

240}
241
242func BenchmarkABACRuleModel(b *testing.B) {
243 e, _ := NewEnforcer("examples/abac_rule_model.conf")
244 sub := newTestSubject("alice", 18)
245
246 for i := 0; i < 1000; i++ {
247 _, _ = e.AddPolicy("r.sub.Age > 20", fmt.Sprintf("data%d", i), "read")
248 }
249
250 b.ResetTimer()
251 for i := 0; i < b.N; i++ {
252 _, _ = e.Enforce(sub, "data100", "read")
253 }
254}
255
256func BenchmarkKeyMatchModel(b *testing.B) {
257 e, _ := NewEnforcer("examples/keymatch_model.conf", "examples/keymatch_policy.csv")

Callers

nothing calls this directly

Calls 4

AddPolicyMethod · 0.95
EnforceMethod · 0.95
NewEnforcerFunction · 0.85
newTestSubjectFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…