(b *testing.B)
| 86 | } |
| 87 | |
| 88 | func BenchmarkRoleManagerLarge(b *testing.B) { |
| 89 | e, _ := NewEnforcer("examples/rbac_model.conf") |
| 90 | |
| 91 | // 10000 roles, 1000 resources. |
| 92 | pPolicies := make([][]string, 0) |
| 93 | for i := 0; i < 10000; i++ { |
| 94 | pPolicies = append(pPolicies, []string{fmt.Sprintf("group%d", i), fmt.Sprintf("data%d", i/10), "read"}) |
| 95 | } |
| 96 | |
| 97 | _, err := e.AddPolicies(pPolicies) |
| 98 | if err != nil { |
| 99 | b.Fatal(err) |
| 100 | } |
| 101 | |
| 102 | // 100000 users. |
| 103 | gPolicies := make([][]string, 0) |
| 104 | for i := 0; i < 100000; i++ { |
| 105 | gPolicies = append(gPolicies, []string{fmt.Sprintf("user%d", i), fmt.Sprintf("group%d", i/10)}) |
| 106 | } |
| 107 | |
| 108 | _, err = e.AddGroupingPolicies(gPolicies) |
| 109 | if err != nil { |
| 110 | b.Fatal(err) |
| 111 | } |
| 112 | |
| 113 | rm := e.GetRoleManager() |
| 114 | |
| 115 | b.ResetTimer() |
| 116 | for i := 0; i < b.N; i++ { |
| 117 | for j := 0; j < 10000; j++ { |
| 118 | _, _ = rm.HasLink("user501", fmt.Sprintf("group%d", j)) |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | func BenchmarkBuildRoleLinksWithPatternLarge(b *testing.B) { |
| 124 | e, _ := NewEnforcer("examples/performance/rbac_with_pattern_large_scale_model.conf", "examples/performance/rbac_with_pattern_large_scale_policy.csv") |
nothing calls this directly
no test coverage detected
searching dependent graphs…