tangled
alpha
login
or
join now
keii.dev
/
osu-framework
0
fork
atom
A game framework written with osu! in mind.
0
fork
atom
overview
issues
pulls
pipelines
Add autosize coverage to spinning boxes benchmark
Dean Herbert
5 years ago
02f94dcc
97241ec9
+36
-4
1 changed file
expand all
collapse all
unified
split
osu.Framework.Benchmarks
BenchmarkManySpinningBoxes.cs
+36
-4
osu.Framework.Benchmarks/BenchmarkManySpinningBoxes.cs
reviewed
···
4
4
using BenchmarkDotNet.Attributes;
5
5
using NUnit.Framework;
6
6
using osu.Framework.Graphics;
7
7
+
using osu.Framework.Graphics.Containers;
7
8
using osu.Framework.Graphics.Shapes;
9
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
16
+
private TestGame game;
17
17
+
14
18
[Test]
15
19
[Benchmark]
16
16
-
public void RunFrame() => RunSingleFrame();
20
20
+
public void RunFrame()
21
21
+
{
22
22
+
game.MainContent.AutoSizeAxes = Axes.None;
23
23
+
game.MainContent.RelativeSizeAxes = Axes.Both;
24
24
+
RunSingleFrame();
25
25
+
}
17
26
18
18
-
protected override Game CreateGame() => new TestGame();
27
27
+
[Test]
28
28
+
[Benchmark]
29
29
+
public void RunFrameWithAutoSize()
30
30
+
{
31
31
+
game.MainContent.RelativeSizeAxes = Axes.None;
32
32
+
game.MainContent.AutoSizeAxes = Axes.Both;
33
33
+
RunSingleFrame();
34
34
+
}
35
35
+
36
36
+
[Test]
37
37
+
[Benchmark]
38
38
+
public void RunFrameWithAutoSizeDuration()
39
39
+
{
40
40
+
game.MainContent.RelativeSizeAxes = Axes.None;
41
41
+
game.MainContent.AutoSizeAxes = Axes.Both;
42
42
+
game.MainContent.AutoSizeDuration = 100;
43
43
+
RunSingleFrame();
44
44
+
}
45
45
+
46
46
+
protected override Game CreateGame() => game = new TestGame();
19
47
20
48
private class TestGame : Game
21
49
{
50
50
+
public Container MainContent;
51
51
+
22
52
protected override void LoadComplete()
23
53
{
24
54
base.LoadComplete();
25
55
56
56
+
Add(MainContent = new Container());
57
57
+
26
58
for (int i = 0; i < 1000; i++)
27
59
{
28
60
var box = new Box
29
61
{
30
30
-
RelativeSizeAxes = Axes.Both,
62
62
+
Size = new Vector2(100),
31
63
Colour = Color4.Black
32
64
};
33
65
34
34
-
Add(box);
66
66
+
MainContent.Add(box);
35
67
36
68
box.Spin(200, RotationDirection.Clockwise);
37
69
}