(b *testing.B)
| 20 | ) |
| 21 | |
| 22 | func BenchmarkHasPolicySmall(b *testing.B) { |
| 23 | e, _ := NewEnforcer("examples/basic_model.conf") |
| 24 | |
| 25 | // 100 roles, 10 resources. |
| 26 | for i := 0; i < 100; i++ { |
| 27 | _, _ = e.AddPolicy(fmt.Sprintf("user%d", i), fmt.Sprintf("data%d", i/10), "read") |
| 28 | } |
| 29 | |
| 30 | b.ResetTimer() |
| 31 | for i := 0; i < b.N; i++ { |
| 32 | e.HasPolicy(fmt.Sprintf("user%d", rand.Intn(100)), fmt.Sprintf("data%d", rand.Intn(100)/10), "read") |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | func BenchmarkHasPolicyMedium(b *testing.B) { |
| 37 | e, _ := NewEnforcer("examples/basic_model.conf") |
nothing calls this directly
no test coverage detected
searching dependent graphs…