(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestBytePool_Memory(t *testing.T) { |
| 12 | var stat1 = &runtime.MemStats{} |
| 13 | runtime.ReadMemStats(stat1) |
| 14 | |
| 15 | var pool = utils.NewBytePool(32 * 1024) |
| 16 | for i := 0; i < 20480; i++ { |
| 17 | pool.Put(&utils.BytesBuf{ |
| 18 | Bytes: make([]byte, 32*1024), |
| 19 | }) |
| 20 | } |
| 21 | |
| 22 | //pool.Purge() |
| 23 | |
| 24 | //time.Sleep(60 * time.Second) |
| 25 | |
| 26 | runtime.GC() |
| 27 | |
| 28 | var stat2 = &runtime.MemStats{} |
| 29 | runtime.ReadMemStats(stat2) |
| 30 | t.Log((stat2.HeapInuse-stat1.HeapInuse)/1024/1024, "MB,") |
| 31 | } |
| 32 | |
| 33 | func BenchmarkBytePool_Get(b *testing.B) { |
| 34 | runtime.GOMAXPROCS(1) |
nothing calls this directly
no test coverage detected