-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added benchmark for fluent RepeatButton.
As that's where #5027 was showing up most.
- Loading branch information
Showing
3 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using System; | ||
using Avalonia.Controls; | ||
using Avalonia.Markup.Xaml; | ||
using Avalonia.Markup.Xaml.Styling; | ||
using Avalonia.Platform; | ||
using Avalonia.Shared.PlatformSupport; | ||
using Avalonia.Styling; | ||
using Avalonia.UnitTests; | ||
using BenchmarkDotNet.Attributes; | ||
using Moq; | ||
|
||
namespace Avalonia.Benchmarks.Themes | ||
{ | ||
[MemoryDiagnoser] | ||
public class FluentBenchmark | ||
{ | ||
private readonly IDisposable _app; | ||
private readonly TestRoot _root; | ||
|
||
public FluentBenchmark() | ||
{ | ||
_app = CreateApp(); | ||
_root = new TestRoot(true, null) | ||
{ | ||
Renderer = new NullRenderer() | ||
}; | ||
|
||
_root.LayoutManager.ExecuteInitialLayoutPass(); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_app.Dispose(); | ||
} | ||
|
||
[Benchmark] | ||
public void RepeatButton() | ||
{ | ||
var button = new RepeatButton(); | ||
_root.Child = button; | ||
_root.LayoutManager.ExecuteLayoutPass(); | ||
} | ||
|
||
private static IDisposable CreateApp() | ||
{ | ||
var services = new TestServices( | ||
assetLoader: new AssetLoader(), | ||
globalClock: new MockGlobalClock(), | ||
platform: new AppBuilder().RuntimePlatform, | ||
renderInterface: new MockPlatformRenderInterface(), | ||
standardCursorFactory: Mock.Of<IStandardCursorFactory>(), | ||
styler: new Styler(), | ||
theme: () => LoadFluentTheme(), | ||
threadingInterface: new NullThreadingPlatform(), | ||
fontManagerImpl: new MockFontManagerImpl(), | ||
textShaperImpl: new MockTextShaperImpl(), | ||
windowingPlatform: new MockWindowingPlatform()); | ||
|
||
return UnitTestApplication.Start(services); | ||
} | ||
|
||
private static Styles LoadFluentTheme() | ||
{ | ||
AssetLoader.RegisterResUriParsers(); | ||
return new Styles | ||
{ | ||
new StyleInclude(new Uri("avares://Avalonia.Benchmarks")) | ||
{ | ||
Source = new Uri("avares://Avalonia.Themes.Fluent/Accents/FluentDark.xaml") | ||
} | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters