A game framework written with osu! in mind.

Add autosize coverage to spinning boxes benchmark

+36 -4
+36 -4
osu.Framework.Benchmarks/BenchmarkManySpinningBoxes.cs
··· 4 4 using BenchmarkDotNet.Attributes; 5 5 using NUnit.Framework; 6 6 using osu.Framework.Graphics; 7 + using osu.Framework.Graphics.Containers; 7 8 using osu.Framework.Graphics.Shapes; 9 + using osuTK; 8 10 using osuTK.Graphics; 9 11 10 12 namespace osu.Framework.Benchmarks 11 13 { 12 14 public class BenchmarkManySpinningBoxes : GameBenchmark 13 15 { 16 + private TestGame game; 17 + 14 18 [Test] 15 19 [Benchmark] 16 - public void RunFrame() => RunSingleFrame(); 20 + public void RunFrame() 21 + { 22 + game.MainContent.AutoSizeAxes = Axes.None; 23 + game.MainContent.RelativeSizeAxes = Axes.Both; 24 + RunSingleFrame(); 25 + } 17 26 18 - protected override Game CreateGame() => new TestGame(); 27 + [Test] 28 + [Benchmark] 29 + public void RunFrameWithAutoSize() 30 + { 31 + game.MainContent.RelativeSizeAxes = Axes.None; 32 + game.MainContent.AutoSizeAxes = Axes.Both; 33 + RunSingleFrame(); 34 + } 35 + 36 + [Test] 37 + [Benchmark] 38 + public void RunFrameWithAutoSizeDuration() 39 + { 40 + game.MainContent.RelativeSizeAxes = Axes.None; 41 + game.MainContent.AutoSizeAxes = Axes.Both; 42 + game.MainContent.AutoSizeDuration = 100; 43 + RunSingleFrame(); 44 + } 45 + 46 + protected override Game CreateGame() => game = new TestGame(); 19 47 20 48 private class TestGame : Game 21 49 { 50 + public Container MainContent; 51 + 22 52 protected override void LoadComplete() 23 53 { 24 54 base.LoadComplete(); 25 55 56 + Add(MainContent = new Container()); 57 + 26 58 for (int i = 0; i < 1000; i++) 27 59 { 28 60 var box = new Box 29 61 { 30 - RelativeSizeAxes = Axes.Both, 62 + Size = new Vector2(100), 31 63 Colour = Color4.Black 32 64 }; 33 65 34 - Add(box); 66 + MainContent.Add(box); 35 67 36 68 box.Spin(200, RotationDirection.Clockwise); 37 69 }