MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / BenchmarkTemplateCC2

Function BenchmarkTemplateCC2

internal/waf/template_test.go:471–501  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

469}
470
471func 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}

Callers

nothing calls this directly

Calls 7

TemplateFunction · 0.92
NewTestRequestFunction · 0.92
FindRuleGroupWithCodeMethod · 0.80
NextMethod · 0.80
StringMethod · 0.45
SetMethod · 0.45
MatchRequestMethod · 0.45

Tested by

no test coverage detected