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

Function BenchmarkAddPolicySmall

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

Source from the content-addressed store, hash-verified

71}
72
73func BenchmarkAddPolicySmall(b *testing.B) {
74 e, _ := NewEnforcer("examples/basic_model.conf")
75
76 // 100 roles, 10 resources.
77 for i := 0; i < 100; i++ {
78 _, _ = e.AddPolicy(fmt.Sprintf("user%d", i), fmt.Sprintf("data%d", i/10), "read")
79 }
80
81 b.ResetTimer()
82 for i := 0; i < b.N; i++ {
83 _, _ = e.AddPolicy(fmt.Sprintf("user%d", rand.Intn(100)+100), fmt.Sprintf("data%d", (rand.Intn(100)+100)/10), "read")
84 }
85}
86
87func BenchmarkAddPolicyMedium(b *testing.B) {
88 e, _ := NewEnforcer("examples/basic_model.conf")

Callers

nothing calls this directly

Calls 2

AddPolicyMethod · 0.95
NewEnforcerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…