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

Function StartMemoryStats

internal/utils/testutils/memory.go:35–57  ·  view source on GitHub ↗
(t *testing.T, callbacks ...func())

Source from the content-addressed store, hash-verified

33}
34
35func StartMemoryStats(t *testing.T, callbacks ...func()) {
36 var ticker = time.NewTicker(1 * time.Second)
37 go func() {
38 var stat = &runtime.MemStats{}
39 var lastHeapInUse uint64
40
41 for range ticker.C {
42 runtime.ReadMemStats(stat)
43 if stat.HeapInuse == lastHeapInUse {
44 continue
45 }
46 lastHeapInUse = stat.HeapInuse
47
48 t.Log(timeutil.Format("H:i:s"), "HeapInuse:", fmt.Sprintf("%.2fM", float64(stat.HeapInuse)/1024/1024), "NumGC:", stat.NumGC)
49
50 if len(callbacks) > 0 {
51 for _, callback := range callbacks {
52 callback()
53 }
54 }
55 }
56 }()
57}
58
59func ReadMemoryStat() *runtime.MemStats {
60 var stat = &runtime.MemStats{}

Callers 3

TestList_MemoryFunction · 0.92
TestCache_MemoryFunction · 0.92

Calls 2

LogMethod · 0.80
FormatMethod · 0.65

Tested by 3

TestList_MemoryFunction · 0.74
TestCache_MemoryFunction · 0.74