A game framework written with osu! in mind.
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.Extensions;
6using osu.Framework.Localisation;
7
8namespace osu.Framework.Benchmarks
9{
10 public class BenchmarkLocalisableDescription
11 {
12 private LocalisableString[] descriptions;
13
14 [Params(1, 10, 100, 1000)]
15 public int Times { get; set; }
16
17 [GlobalSetup]
18 public void SetUp()
19 {
20 descriptions = new LocalisableString[Times];
21 }
22
23 [Benchmark]
24 public LocalisableString[] GetLocalisableDescription()
25 {
26 for (int i = 0; i < Times; i++)
27 descriptions[i] = TestLocalisableEnum.One.GetLocalisableDescription();
28
29 return descriptions;
30 }
31
32 private enum TestLocalisableEnum
33 {
34 [LocalisableDescription(typeof(TestStrings), nameof(TestStrings.One))]
35 One,
36 }
37
38 private static class TestStrings
39 {
40 public static LocalisableString One => "1";
41 }
42 }
43}