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

Function BenchmarkTemplate

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

Source from the content-addressed store, hash-verified

67}
68
69func BenchmarkTemplate(b *testing.B) {
70 runtime.GOMAXPROCS(4)
71
72 wafInstance, err := waf.Template()
73 if err != nil {
74 b.Fatal(err)
75 }
76
77 b.ResetTimer()
78
79 b.RunParallel(func(pb *testing.PB) {
80 for pb.Next() {
81 req, err := http.NewRequest(http.MethodGet, "https://example.com/index.php?id=123"+types.String(rand.Int()%10000), nil)
82 if err != nil {
83 b.Fatal(err)
84 }
85 req.Header.Set("User-Agent", testUserAgent)
86
87 _, _ = wafInstance.MatchRequest(requests.NewTestRequest(req), nil, firewallconfigs.ServerCaptchaTypeNone)
88 }
89 })
90}
91
92func testTemplate1010(a *assert.Assertion, t *testing.T, template *waf.WAF) {
93 for _, id := range []string{

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected