MCPcopy Index your code
hub / github.com/apache/casbin / BenchmarkCachedRBACModelSmall

Function BenchmarkCachedRBACModelSmall

enforcer_cached_b_test.go:46–67  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

44}
45
46func BenchmarkCachedRBACModelSmall(b *testing.B) {
47 e, _ := NewCachedEnforcer("examples/rbac_model.conf")
48 // 100 roles, 10 resources.
49 for i := 0; i < 100; i++ {
50 _, err := e.AddPolicy(fmt.Sprintf("group%d", i), fmt.Sprintf("data%d", i/10), "read")
51 if err != nil {
52 b.Fatal(err)
53 }
54 }
55 // 1000 users.
56 for i := 0; i < 1000; i++ {
57 _, err := e.AddGroupingPolicy(fmt.Sprintf("user%d", i), fmt.Sprintf("group%d", i/10))
58 if err != nil {
59 b.Fatal(err)
60 }
61 }
62
63 b.ResetTimer()
64 for i := 0; i < b.N; i++ {
65 _, _ = e.Enforce("user501", "data9", "read")
66 }
67}
68
69func BenchmarkCachedRBACModelMedium(b *testing.B) {
70 e, _ := NewCachedEnforcer("examples/rbac_model.conf")

Callers

nothing calls this directly

Calls 4

EnforceMethod · 0.95
NewCachedEnforcerFunction · 0.85
AddPolicyMethod · 0.65
AddGroupingPolicyMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…