(t *testing.T)
| 136 | } |
| 137 | |
| 138 | func TestAntsPoolWithFuncWaitToGetWorkerPreMalloc(t *testing.T) { |
| 139 | var wg sync.WaitGroup |
| 140 | p, _ := ants.NewPoolWithFunc(AntsSize, func(i any) { |
| 141 | demoPoolFunc(i) |
| 142 | wg.Done() |
| 143 | }, ants.WithPreAlloc(true)) |
| 144 | defer p.Release() |
| 145 | |
| 146 | for i := 0; i < n; i++ { |
| 147 | wg.Add(1) |
| 148 | _ = p.Invoke(Param) |
| 149 | } |
| 150 | wg.Wait() |
| 151 | t.Logf("pool with func, running workers number:%d", p.Running()) |
| 152 | mem := runtime.MemStats{} |
| 153 | runtime.ReadMemStats(&mem) |
| 154 | curMem = mem.TotalAlloc/MiB - curMem |
| 155 | t.Logf("memory usage:%d MB", curMem) |
| 156 | } |
| 157 | |
| 158 | func TestAntsPoolWithFuncGenericWaitToGetWorkerPreMalloc(t *testing.T) { |
| 159 | var wg sync.WaitGroup |
nothing calls this directly
no test coverage detected
searching dependent graphs…