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

Function TestItems_Memory2

internal/caches/item_test.go:75–107  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

73}
74
75func TestItems_Memory2(t *testing.T) {
76 var stat = &runtime.MemStats{}
77 runtime.ReadMemStats(stat)
78 var memory1 = stat.HeapInuse
79
80 var items = map[int32]map[string]zero.Zero{}
81 var count = 100
82 if testutils.IsSingleTesting() {
83 count = 10_000_000
84 }
85
86 for i := 0; i < count; i++ {
87 var week = int32((time.Now().Unix() - int64(86400*rands.Int(0, 300))) / (86400 * 7))
88 m, ok := items[week]
89 if !ok {
90 m = map[string]zero.Zero{}
91 items[week] = m
92 }
93 m[types.String(int64(i)*1_000_000)] = zero.New()
94 }
95
96 runtime.ReadMemStats(stat)
97 var memory2 = stat.HeapInuse
98
99 t.Log(memory1, memory2, (memory2-memory1)/1024/1024, "M")
100
101 if testutils.IsSingleTesting() {
102 time.Sleep(1 * time.Second)
103 }
104 for w, i := range items {
105 t.Log(w, len(i))
106 }
107}
108
109func TestItem_RequestURI(t *testing.T) {
110 for _, u := range []string{

Callers

nothing calls this directly

Calls 5

IsSingleTestingFunction · 0.92
NewFunction · 0.92
UnixMethod · 0.80
LogMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected