优化一处测试用例

This commit is contained in:
刘祥超
2023-10-09 08:51:03 +08:00
parent 38a214878a
commit 6bff5c978b

View File

@@ -178,14 +178,25 @@ func TestMemoryFragmentPool_GCNextBucket(t *testing.T) {
} }
var pool = caches.NewMemoryFragmentPool() var pool = caches.NewMemoryFragmentPool()
for i := 0; i < 100; i++ { for i := 0; i < 1000; i++ {
pool.Put(make([]byte, 2<<20)) pool.Put(make([]byte, rands.Int(0, 100)<<20))
} }
for i := 0; i < 100; i++ { var lastLen int
for {
pool.GCNextBucket() pool.GCNextBucket()
t.Log(pool.Len(), timeutil.Format("H:i:s")) var currentLen = pool.Len()
time.Sleep(10 * time.Second) if lastLen == currentLen {
continue
}
lastLen = currentLen
t.Log(currentLen, "items", pool.TotalSize(), "bytes", timeutil.Format("H:i:s"))
time.Sleep(100 * time.Millisecond)
if currentLen == 0 {
break
}
} }
} }