(b *testing.B)
| 469 | } |
| 470 | |
| 471 | func BenchmarkTemplateCC2(b *testing.B) { |
| 472 | runtime.GOMAXPROCS(4) |
| 473 | |
| 474 | template, err := waf.Template() |
| 475 | if err != nil { |
| 476 | b.Fatal(err) |
| 477 | } |
| 478 | var group = template.FindRuleGroupWithCode("cc2") |
| 479 | if group == nil { |
| 480 | b.Fatal("group not found") |
| 481 | return |
| 482 | } |
| 483 | |
| 484 | b.ResetTimer() |
| 485 | |
| 486 | b.RunParallel(func(pb *testing.PB) { |
| 487 | for pb.Next() { |
| 488 | req, err := http.NewRequest(http.MethodPost, "https://example.com/?id=1234"+types.String(rand.Int()%10000)+"&name=lily&time=12345678910", nil) |
| 489 | if err != nil { |
| 490 | b.Fatal(err) |
| 491 | } |
| 492 | req.Header.Set("User-Agent", testUserAgent) |
| 493 | |
| 494 | _, _, result, err := group.MatchRequest(requests.NewTestRequest(req)) |
| 495 | if err != nil { |
| 496 | b.Fatal(err) |
| 497 | } |
| 498 | _ = result |
| 499 | } |
| 500 | }) |
| 501 | } |
nothing calls this directly
no test coverage detected