コード例 #1
0
 public void ShrinkKeepsPoolSizePlusPercent()
 {
     GitIndexProjection.ObjectPool <object> pool = CreateExpandedPool();
     pool.Shrink();
     pool.Size.ShouldEqual(DefaultShrinkSize);
     UseObjectsInPool(pool, DefaultObjectsToUse);
     pool.Size.ShouldEqual(PoolSizeAfterExpandingAfterShrinking);
     pool.FreeAll();
     UseObjectsInPool(pool, DefaultObjectsToUse);
     pool.Size.ShouldEqual(PoolSizeAfterExpandingAfterShrinking);
     pool.Shrink();
     pool.Size.ShouldEqual(DefaultShrinkSize);
 }
コード例 #2
0
 public void ShrinkKeepsUsedObjectsPlusPercent()
 {
     GitIndexProjection.ObjectPool <object> pool = new GitIndexProjection.ObjectPool <object>(new MockTracer(), AllocationSize, objectCreator: () => new object());
     UseObjectsInPool(pool, 20);
     pool.Size.ShouldEqual(AllocationSize);
     pool.Shrink();
     pool.Size.ShouldEqual(Convert.ToInt32(20 * 1.1));
 }
コード例 #3
0
 public void FreeToZeroAllocatesMinimumSizeNextGet()
 {
     GitIndexProjection.ObjectPool <object> pool = new GitIndexProjection.ObjectPool <object>(new MockTracer(), AllocationSize, objectCreator: () => new object());
     pool.FreeAll();
     pool.Shrink();
     pool.Size.ShouldEqual(0);
     UseObjectsInPool(pool, 1);
     pool.Size.ShouldEqual(AllocationSize);
 }