MCPcopy Create free account
hub / github.com/PuerkitoBio/fetchbot / runMemStats

Function runMemStats

example/full/main.go:127–148  ·  view source on GitHub ↗
(f *fetchbot.Fetcher, tick time.Duration)

Source from the content-addressed store, hash-verified

125}
126
127func runMemStats(f *fetchbot.Fetcher, tick time.Duration) {
128 var mu sync.Mutex
129 var di *fetchbot.DebugInfo
130
131 // Start goroutine to collect fetchbot debug info
132 go func() {
133 for v := range f.Debug() {
134 mu.Lock()
135 di = v
136 mu.Unlock()
137 }
138 }()
139 // Start ticker goroutine to print mem stats at regular intervals
140 go func() {
141 c := time.Tick(tick)
142 for _ = range c {
143 mu.Lock()
144 printMemStats(di)
145 mu.Unlock()
146 }
147 }()
148}
149
150func printMemStats(di *fetchbot.DebugInfo) {
151 var mem runtime.MemStats

Callers 1

mainFunction · 0.85

Calls 2

printMemStatsFunction · 0.85
DebugMethod · 0.80

Tested by

no test coverage detected