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

Function TestIPItem_Memory

internal/iplibrary/ip_item_test.go:81–106  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

79}
80
81func TestIPItem_Memory(t *testing.T) {
82 var isSingleTest = testutils.IsSingleTesting()
83
84 var list = iplibrary.NewIPList()
85 var count = 100
86 if isSingleTest {
87 count = 2_000_000
88 }
89 for i := 0; i < count; i++ {
90 list.Add(&iplibrary.IPItem{
91 Type: "ip",
92 Id: uint64(i),
93 IPFrom: iputils.ToBytes("192.168.1.1"),
94 IPTo: nil,
95 ExpiredAt: time.Now().Unix(),
96 EventLevel: "",
97 })
98 }
99
100 runtime.GC()
101
102 t.Log("waiting")
103 if isSingleTest {
104 time.Sleep(10 * time.Second)
105 }
106}
107
108func BenchmarkIPItem_Contains(b *testing.B) {
109 runtime.GOMAXPROCS(1)

Callers

nothing calls this directly

Calls 6

IsSingleTestingFunction · 0.92
NewIPListFunction · 0.92
UnixMethod · 0.80
LogMethod · 0.80
AddMethod · 0.65
GCMethod · 0.65

Tested by

no test coverage detected