forked from projectdiscovery/nuclei
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions_bench_test.go
More file actions
45 lines (37 loc) · 943 Bytes
/
Copy pathoptions_bench_test.go
File metadata and controls
45 lines (37 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package generators
import (
"testing"
"github.com/projectdiscovery/goflags"
"github.com/projectdiscovery/nuclei/v3/pkg/types"
)
func BenchmarkBuildPayloadFromOptions(b *testing.B) {
// Setup options with vars and env vars
vars := goflags.RuntimeMap{}
_ = vars.Set("key1=value1")
_ = vars.Set("key2=value2")
_ = vars.Set("key3=value3")
_ = vars.Set("key4=value4")
_ = vars.Set("key5=value5")
opts := &types.Options{
Vars: vars,
EnvironmentVariables: true, // This adds more entries
}
b.Run("Sequential", func(b *testing.B) {
ClearOptionsPayloadMap(opts)
b.ReportAllocs()
for b.Loop() {
_ = BuildPayloadFromOptions(opts)
}
})
b.Run("Parallel", func(b *testing.B) {
ClearOptionsPayloadMap(opts)
b.ReportAllocs()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
m := BuildPayloadFromOptions(opts)
// Simulate typical usage - read a value
_ = m["key1"]
}
})
})
}