A game framework written with osu! in mind.
at master 1.5 kB view raw
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2// See the LICENCE file in the repository root for full licence text. 3 4using BenchmarkDotNet.Attributes; 5using osu.Framework.Graphics; 6using osu.Framework.Graphics.Shapes; 7using osu.Framework.Timing; 8using osuTK; 9 10namespace osu.Framework.Benchmarks 11{ 12 public class BenchmarkTransformUpdate : BenchmarkTest 13 { 14 private TestBox target; 15 16 public override void SetUp() 17 { 18 base.SetUp(); 19 20 const int transforms_count = 10000; 21 22 ManualClock clock; 23 24 target = new TestBox { Clock = new FramedClock(clock = new ManualClock()) }; 25 26 // transform one target member over a long period 27 target.RotateTo(360, transforms_count * 2); 28 29 // transform another over the same period many times 30 for (int i = 0; i < transforms_count; i++) 31 target.Delay(i).MoveTo(new Vector2(0.01f), 1f); 32 33 clock.CurrentTime = target.LatestTransformEndTime; 34 target.Clock.ProcessFrame(); 35 } 36 37 [Benchmark] 38 public void UpdateTransformsWithManyPresent() 39 { 40 for (int i = 0; i < 10000; i++) 41 target.UpdateTransforms(); 42 } 43 44 private class TestBox : Box 45 { 46 public override bool RemoveCompletedTransforms => false; 47 48 public new void UpdateTransforms() => base.UpdateTransforms(); 49 } 50 } 51}