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); }
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)); }
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); }