(b *testing.B)
| 103 | } |
| 104 | |
| 105 | func BenchmarkAddPolicyLarge(b *testing.B) { |
| 106 | e, _ := NewEnforcer("examples/basic_model.conf") |
| 107 | |
| 108 | // 10000 roles, 1000 resources. |
| 109 | pPolicies := make([][]string, 0) |
| 110 | for i := 0; i < 10000; i++ { |
| 111 | pPolicies = append(pPolicies, []string{fmt.Sprintf("user%d", i), fmt.Sprintf("data%d", i/10), "read"}) |
| 112 | } |
| 113 | _, err := e.AddPolicies(pPolicies) |
| 114 | if err != nil { |
| 115 | b.Fatal(err) |
| 116 | } |
| 117 | |
| 118 | b.ResetTimer() |
| 119 | for i := 0; i < b.N; i++ { |
| 120 | _, _ = e.AddPolicy(fmt.Sprintf("user%d", rand.Intn(10000)+10000), fmt.Sprintf("data%d", (rand.Intn(10000)+10000)/10), "read") |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | func BenchmarkRemovePolicySmall(b *testing.B) { |
| 125 | e, _ := NewEnforcer("examples/basic_model.conf") |
nothing calls this directly
no test coverage detected
searching dependent graphs…