Path: blob/dev/pkg/protocols/common/generators/options_bench_test.go
2843 views
package generators12import (3"testing"45"github.com/projectdiscovery/goflags"6"github.com/projectdiscovery/nuclei/v3/pkg/types"7)89func BenchmarkBuildPayloadFromOptions(b *testing.B) {10// Setup options with vars and env vars11vars := goflags.RuntimeMap{}12_ = vars.Set("key1=value1")13_ = vars.Set("key2=value2")14_ = vars.Set("key3=value3")15_ = vars.Set("key4=value4")16_ = vars.Set("key5=value5")1718opts := &types.Options{19Vars: vars,20EnvironmentVariables: true, // This adds more entries21}2223b.Run("Sequential", func(b *testing.B) {24ClearOptionsPayloadMap(opts)2526b.ReportAllocs()27for b.Loop() {28_ = BuildPayloadFromOptions(opts)29}30})3132b.Run("Parallel", func(b *testing.B) {33ClearOptionsPayloadMap(opts)3435b.ReportAllocs()36b.RunParallel(func(pb *testing.PB) {37for pb.Next() {38m := BuildPayloadFromOptions(opts)39// Simulate typical usage - read a value40_ = m["key1"]41}42})43})44}454647