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

Function TestBytePool_Memory

internal/utils/byte_pool_test.go:11–31  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func 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
33func BenchmarkBytePool_Get(b *testing.B) {
34 runtime.GOMAXPROCS(1)

Callers

nothing calls this directly

Calls 4

NewBytePoolFunction · 0.92
LogMethod · 0.80
GCMethod · 0.65
PutMethod · 0.45

Tested by

no test coverage detected