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

Function BenchmarkTemplatePathTraversal

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

Source from the content-addressed store, hash-verified

437}
438
439func BenchmarkTemplatePathTraversal(b *testing.B) {
440 runtime.GOMAXPROCS(4)
441
442 template, err := waf.Template()
443 if err != nil {
444 b.Fatal(err)
445 }
446 var group = template.FindRuleGroupWithCode("pathTraversal")
447 if group == nil {
448 b.Fatal("group not found")
449 return
450 }
451
452 b.ResetTimer()
453
454 b.RunParallel(func(pb *testing.PB) {
455 for pb.Next() {
456 req, err := http.NewRequest(http.MethodPost, "https://example.com/?id=1234"+types.String(rand.Int()%10000)+"&name=lily&time=12345678910", nil)
457 if err != nil {
458 b.Fatal(err)
459 }
460 req.Header.Set("User-Agent", testUserAgent)
461
462 _, _, result, err := group.MatchRequest(requests.NewTestRequest(req))
463 if err != nil {
464 b.Fatal(err)
465 }
466 _ = result
467 }
468 })
469}
470
471func BenchmarkTemplateCC2(b *testing.B) {
472 runtime.GOMAXPROCS(4)

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