Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/CommunityToolkit.Maui.Markup.Benchmarks/BaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static void CreateAndSetMockApplication(out IServiceProvider serviceProvider)
.UseMauiApp<MockApplication>();

appBuilder.Services.AddSingleton<IDispatcher>(_ => new MockDispatcherProvider().GetForCurrentThread());

var mauiApp = appBuilder.Build();

var application = mauiApp.Services.GetRequiredService<IApplication>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace CommunityToolkit.Maui.Markup.Benchmarks;
public abstract class ExecuteBindingsBase : BaseTest
{
protected const string helloWorldText = "Hello World";

protected ExecuteBindingsBase()
{
DefaultBindingsLabel = new()
Expand All @@ -17,16 +17,16 @@ protected ExecuteBindingsBase()
DefaultBindingsLabel.EnableAnimations();

DefaultMarkupBindingsLabel = new Label
{
BindingContext = DefaultMarkupBindingsLabelViewModel
}.Bind(Label.TextProperty, nameof(LabelViewModel.Text), mode: BindingMode.TwoWay)
{
BindingContext = DefaultMarkupBindingsLabelViewModel
}.Bind(Label.TextProperty, nameof(LabelViewModel.Text), mode: BindingMode.TwoWay)
.Bind(Label.TextColorProperty, nameof(LabelViewModel.TextColor), mode: BindingMode.TwoWay);
DefaultMarkupBindingsLabel.EnableAnimations();

TypedMarkupBindingsLabel = new Label
{
BindingContext = TypedMarkupBindingsLabelViewModel
}.Bind(Label.TextProperty,
{
BindingContext = TypedMarkupBindingsLabelViewModel
}.Bind(Label.TextProperty,
getter: (LabelViewModel vm) => vm.Text,
setter: (LabelViewModel vm, string text) => vm.Text = text,
mode: BindingMode.TwoWay)
Expand All @@ -36,12 +36,12 @@ protected ExecuteBindingsBase()
mode: BindingMode.TwoWay);
TypedMarkupBindingsLabel.EnableAnimations();
}

protected LabelViewModel DefaultBindingsLabelViewModel { get; } = new();
protected LabelViewModel DefaultMarkupBindingsLabelViewModel { get; } = new();
protected LabelViewModel TypedMarkupBindingsLabelViewModel { get; } = new();

protected Label DefaultBindingsLabel { get; }
protected Label DefaultMarkupBindingsLabel{ get; }
protected Label TypedMarkupBindingsLabel{ get; }
protected Label DefaultMarkupBindingsLabel { get; }
protected Label TypedMarkupBindingsLabel { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ public class InitializeBindings : BaseTest
{
BindingContext = new LabelViewModel()
};

readonly Label defaultMarkupBindingsLabel = new()
{
BindingContext = new LabelViewModel()
};

readonly Label typedMarkupBindingsLabel = new()
{
BindingContext = new LabelViewModel()
Expand All @@ -26,15 +26,15 @@ public void InitializeDefaultBindings()
defaultBindingsLabel.SetBinding(Label.TextProperty, nameof(LabelViewModel.Text), mode: BindingMode.TwoWay);
defaultBindingsLabel.SetBinding(Label.TextColorProperty, nameof(LabelViewModel.TextColor), mode: BindingMode.TwoWay);
}

[Benchmark]
public void InitializeDefaultBindingsMarkup()
{
defaultMarkupBindingsLabel
.Bind(Label.TextProperty, nameof(LabelViewModel.Text), mode: BindingMode.TwoWay)
.Bind(Label.TextColorProperty, nameof(LabelViewModel.TextColor), mode: BindingMode.TwoWay);
}

[Benchmark]
public void InitializeTypedBindingsMarkup()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public object GetService(Type serviceType)
{
return AnimationManager;
}

if (serviceType == typeof(IDispatcher))
{
return new MockDispatcherProvider().GetForCurrentThread();
Expand Down
2 changes: 1 addition & 1 deletion src/CommunityToolkit.Maui.Markup.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class Program
public static void Main(string[] args)
{
var config = DefaultConfig.Instance;

BenchmarkRunner.Run<InitializeBindings>(config, args);
BenchmarkRunner.Run<ExecuteBindings_ViewModelToView>(config, args);
BenchmarkRunner.Run<ExecuteBindings_ViewToViewModel>(config, args);
Expand Down