(b *testing.B)
| 34 | } |
| 35 | |
| 36 | func BenchmarkHasPolicyMedium(b *testing.B) { |
| 37 | e, _ := NewEnforcer("examples/basic_model.conf") |
| 38 | |
| 39 | // 1000 roles, 100 resources. |
| 40 | pPolicies := make([][]string, 0) |
| 41 | for i := 0; i < 1000; i++ { |
| 42 | pPolicies = append(pPolicies, []string{fmt.Sprintf("user%d", i), fmt.Sprintf("data%d", i/10), "read"}) |
| 43 | } |
| 44 | _, err := e.AddPolicies(pPolicies) |
| 45 | if err != nil { |
| 46 | b.Fatal(err) |
| 47 | } |
| 48 | b.ResetTimer() |
| 49 | for i := 0; i < b.N; i++ { |
| 50 | e.HasPolicy(fmt.Sprintf("user%d", rand.Intn(1000)), fmt.Sprintf("data%d", rand.Intn(1000)/10), "read") |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | func BenchmarkHasPolicyLarge(b *testing.B) { |
| 55 | e, _ := NewEnforcer("examples/basic_model.conf") |
nothing calls this directly
no test coverage detected
searching dependent graphs…