(b *testing.B)
| 52 | } |
| 53 | |
| 54 | func BenchmarkHasPolicyLarge(b *testing.B) { |
| 55 | e, _ := NewEnforcer("examples/basic_model.conf") |
| 56 | |
| 57 | // 10000 roles, 1000 resources. |
| 58 | pPolicies := make([][]string, 0) |
| 59 | for i := 0; i < 10000; i++ { |
| 60 | pPolicies = append(pPolicies, []string{fmt.Sprintf("user%d", i), fmt.Sprintf("data%d", i/10), "read"}) |
| 61 | } |
| 62 | _, err := e.AddPolicies(pPolicies) |
| 63 | if err != nil { |
| 64 | b.Fatal(err) |
| 65 | } |
| 66 | |
| 67 | b.ResetTimer() |
| 68 | for i := 0; i < b.N; i++ { |
| 69 | e.HasPolicy(fmt.Sprintf("user%d", rand.Intn(10000)), fmt.Sprintf("data%d", rand.Intn(10000)/10), "read") |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | func BenchmarkAddPolicySmall(b *testing.B) { |
| 74 | e, _ := NewEnforcer("examples/basic_model.conf") |
nothing calls this directly
no test coverage detected
searching dependent graphs…