From 534521ad6bc696b34f0b10412f4d92ffc6dc76bf Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 7 Nov 2024 13:55:36 +0100 Subject: [PATCH] fixed TestPackTimes on KNI --- Tests/TexturePackerTests.cs | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/Tests/TexturePackerTests.cs b/Tests/TexturePackerTests.cs index 3d0cebe2..92cfae38 100644 --- a/Tests/TexturePackerTests.cs +++ b/Tests/TexturePackerTests.cs @@ -121,24 +121,23 @@ public void TestPackMultipleTimes() { } [Test] - public void TestPackTimes() { + public void TestPackTimes([Values(1, 100, 1000, 5000, 10000)] int total) { var random = new Random(1238492384); - for (var total = 1; total <= 10001; total += 1000) { - using var sameSizePacker = new RuntimeTexturePacker(); - using var diffSizePacker = new RuntimeTexturePacker(); - for (var i = 0; i < total; i++) { - sameSizePacker.Add(new TextureRegion(this.testTexture, 0, 0, 10, 10), TexturePackerTests.StubResult); - diffSizePacker.Add(new TextureRegion(this.testTexture, 0, 0, random.Next(10, 200), random.Next(10, 200)), TexturePackerTests.StubResult); - } - sameSizePacker.Pack(this.Game.GraphicsDevice); - diffSizePacker.Pack(this.Game.GraphicsDevice); - - TestContext.WriteLine($""" - {total} regions, - same-size {sameSizePacker.LastCalculationTime.TotalMilliseconds} calc, {sameSizePacker.LastPackTime.TotalMilliseconds} pack, {sameSizePacker.LastTotalTime.TotalMilliseconds} total, - diff-size {diffSizePacker.LastCalculationTime.TotalMilliseconds} calc, {diffSizePacker.LastPackTime.TotalMilliseconds} pack, {diffSizePacker.LastTotalTime.TotalMilliseconds} total - """); + var width = total >= 5000 ? 8192 : 2048; + using var sameSizePacker = new RuntimeTexturePacker(width); + using var diffSizePacker = new RuntimeTexturePacker(width); + for (var i = 0; i < total; i++) { + sameSizePacker.Add(new TextureRegion(this.testTexture, 0, 0, 10, 10), TexturePackerTests.StubResult); + diffSizePacker.Add(new TextureRegion(this.testTexture, 0, 0, random.Next(10, 200), random.Next(10, 200)), TexturePackerTests.StubResult); } + sameSizePacker.Pack(this.Game.GraphicsDevice); + diffSizePacker.Pack(this.Game.GraphicsDevice); + + TestContext.WriteLine($""" + {total} regions, + same-size {sameSizePacker.LastCalculationTime.TotalMilliseconds}ms calc, {sameSizePacker.LastPackTime.TotalMilliseconds}ms pack, {sameSizePacker.LastTotalTime.TotalMilliseconds}ms total, + diff-size {diffSizePacker.LastCalculationTime.TotalMilliseconds}ms calc, {diffSizePacker.LastPackTime.TotalMilliseconds}ms pack, {diffSizePacker.LastTotalTime.TotalMilliseconds}ms total + """); } private static void StubResult(TextureRegion region) {}