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

Function BenchmarkRBACModelSmall

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

Source from the content-addressed store, hash-verified

125}
126
127func BenchmarkRBACModelSmall(b *testing.B) {
128 e, _ := NewEnforcer("examples/rbac_model.conf")
129
130 // 100 roles, 10 resources.
131 for i := 0; i < 100; i++ {
132 _, err := e.AddPolicy(fmt.Sprintf("group%d", i), fmt.Sprintf("data%d", i/10), "read")
133 if err != nil {
134 b.Fatal(err)
135 }
136 }
137
138 // 1000 users.
139 for i := 0; i < 1000; i++ {
140 _, err := e.AddGroupingPolicy(fmt.Sprintf("user%d", i), fmt.Sprintf("group%d", i/10))
141 if err != nil {
142 b.Fatal(err)
143 }
144 }
145
146 b.ResetTimer()
147 for i := 0; i < b.N; i++ {
148 _, _ = e.Enforce("user501", "data9", "read")
149 }
150}
151
152func BenchmarkRBACModelMedium(b *testing.B) {
153 e, _ := NewEnforcer("examples/rbac_model.conf")

Callers

nothing calls this directly

Calls 4

AddPolicyMethod · 0.95
AddGroupingPolicyMethod · 0.95
EnforceMethod · 0.95
NewEnforcerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…