mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 07:40:56 +08:00 
			
		
		
		
	优化一处测试用例
This commit is contained in:
		@@ -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
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user