A game framework written with osu! in mind.
at master 1.3 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 System; 5using BenchmarkDotNet.Attributes; 6using osu.Framework.Configuration; 7using osu.Framework.Localisation; 8using osu.Framework.Testing; 9 10namespace osu.Framework.Benchmarks 11{ 12 [MemoryDiagnoser] 13 public class BenchmarkLocalisedBindableString 14 { 15 private LocalisationManager manager; 16 private TemporaryNativeStorage storage; 17 18 [GlobalSetup] 19 public void GlobalSetup() 20 { 21 storage = new TemporaryNativeStorage(new Guid().ToString()); 22 manager = new LocalisationManager(new FrameworkConfigManager(storage)); 23 } 24 25 [GlobalCleanup] 26 public void GlobalCleanup() 27 { 28 storage.Dispose(); 29 } 30 31 [Benchmark] 32 public void BenchmarkNonLocalised() 33 { 34 var bindable = manager.GetLocalisedString("test"); 35 bindable.UnbindAll(); 36 } 37 38 [Benchmark] 39 public void BenchmarkLocalised() 40 { 41 var bindable = manager.GetLocalisedString(new TranslatableString("test", "test")); 42 bindable.UnbindAll(); 43 } 44 } 45}