MCPcopy
hub / github.com/panjf2000/ants / TestAntsPoolWithFuncGenericGetWorkerFromCache

Function TestAntsPoolWithFuncGenericGetWorkerFromCache

ants_test.go:214–229  ·  view source on GitHub ↗

TestAntsPoolWithFuncGenericGetWorkerFromCache is used to test getting worker from sync.Pool.

(t *testing.T)

Source from the content-addressed store, hash-verified

212
213// TestAntsPoolWithFuncGenericGetWorkerFromCache is used to test getting worker from sync.Pool.
214func TestAntsPoolWithFuncGenericGetWorkerFromCache(t *testing.T) {
215 dur := 10
216 p, _ := ants.NewPoolWithFuncGeneric(TestSize, demoPoolFuncInt)
217 defer p.Release()
218
219 for i := 0; i < AntsSize; i++ {
220 _ = p.Invoke(dur)
221 }
222 time.Sleep(2 * ants.DefaultCleanIntervalTime)
223 _ = p.Invoke(dur)
224 t.Logf("pool with func, running workers number:%d", p.Running())
225 mem := runtime.MemStats{}
226 runtime.ReadMemStats(&mem)
227 curMem = mem.TotalAlloc/MiB - curMem
228 t.Logf("memory usage:%d MB", curMem)
229}
230
231func TestAntsPoolWithFuncGetWorkerFromCachePreMalloc(t *testing.T) {
232 dur := 10

Callers

nothing calls this directly

Calls 3

ReleaseMethod · 0.80
InvokeMethod · 0.45
RunningMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…