From a5ad3cf4fe7844bf9f051e8189de278a14e94e36 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Wed, 19 Jun 2024 15:45:23 -0700 Subject: [PATCH 01/25] Add Benchmarks --- .../BaseTest.cs | 60 +++++++ ...enchmarks.ExecuteBindings-report-github.md | 19 +++ ...rkup.Benchmarks.ExecuteBindings-report.csv | 4 + ...kup.Benchmarks.ExecuteBindings-report.html | 31 ++++ ...hmarks.InitializeBindings-report-github.md | 15 ++ ...p.Benchmarks.InitializeBindings-report.csv | 4 + ....Benchmarks.InitializeBindings-report.html | 32 ++++ .../Benchmarks/ExecuteBindings.cs | 64 ++++++++ .../Benchmarks/InitializeBindings.cs | 47 ++++++ ...unityToolkit.Maui.Markup.Benchmarks.csproj | 31 ++++ .../Extensions/AnimationExtensions.cs | 148 ++++++++++++++++++ .../LabelViewModel.cs | 12 ++ .../Mocks/HandlerContextStub.cs | 19 +++ .../Mocks/MockApplication.cs | 21 +++ .../Mocks/MockDispatcherProvider.cs | 71 +++++++++ .../Program.cs | 13 ++ .../Mocks/MockDispatcherProvider.cs | 11 +- src/CommunityToolkit.Maui.Markup.sln | 6 + 18 files changed, 599 insertions(+), 9 deletions(-) create mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/BaseTest.cs create mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report-github.md create mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report.csv create mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report.html create mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report-github.md create mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report.csv create mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report.html create mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindings.cs create mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/InitializeBindings.cs create mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/CommunityToolkit.Maui.Markup.Benchmarks.csproj create mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/Extensions/AnimationExtensions.cs create mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/LabelViewModel.cs create mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/Mocks/HandlerContextStub.cs create mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/Mocks/MockApplication.cs create mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/Mocks/MockDispatcherProvider.cs create mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/Program.cs diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/BaseTest.cs b/src/CommunityToolkit.Maui.Markup.Benchmarks/BaseTest.cs new file mode 100644 index 00000000..0f647147 --- /dev/null +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/BaseTest.cs @@ -0,0 +1,60 @@ +using CommunityToolkit.Maui.Markup.Benchmarks.Mocks; + +namespace CommunityToolkit.Maui.Markup.Benchmarks; + +public abstract class BaseTest +{ + protected BaseTest() + { + CreateAndSetMockApplication(out var serviceProvider); + ServiceProvider = serviceProvider; + } + + protected IServiceProvider ServiceProvider { get; } + + protected static TElementHandler CreateElementHandler(IElement view, bool hasMauiContext = true) + where TElementHandler : IElementHandler, new() + { + var mockElementHandler = new TElementHandler(); + mockElementHandler.SetVirtualView(view); + + if (hasMauiContext) + { + mockElementHandler.SetMauiContext(Application.Current?.Handler?.MauiContext ?? throw new NullReferenceException()); + } + + return mockElementHandler; + } + + protected static TViewHandler CreateViewHandler(IView view, bool hasMauiContext = true) + where TViewHandler : IViewHandler, new() + { + var mockViewHandler = new TViewHandler(); + mockViewHandler.SetVirtualView(view); + + if (hasMauiContext) + { + mockViewHandler.SetMauiContext(Application.Current?.Handler?.MauiContext ?? throw new NullReferenceException()); + } + + return mockViewHandler; + } + + static void CreateAndSetMockApplication(out IServiceProvider serviceProvider) + { + var appBuilder = MauiApp.CreateBuilder() + .UseMauiApp(); + + appBuilder.Services.AddSingleton(_ => new MockDispatcherProvider().GetForCurrentThread()); + + var mauiApp = appBuilder.Build(); + + var application = mauiApp.Services.GetRequiredService(); + serviceProvider = mauiApp.Services; + + IPlatformApplication.Current = (IPlatformApplication)application; + + application.Handler = new ApplicationHandlerStub(); + application.Handler.SetMauiContext(new HandlersContextStub(mauiApp.Services)); + } +} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report-github.md b/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report-github.md new file mode 100644 index 00000000..561a2bd8 --- /dev/null +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report-github.md @@ -0,0 +1,19 @@ +``` + +BenchmarkDotNet v0.13.12, macOS Sonoma 14.5 (23F79) [Darwin 23.5.0] +Apple M2 Max, 1 CPU, 12 logical and 12 physical cores +.NET SDK 8.0.302 + [Host] : .NET 8.0.6 (8.0.624.26715), Arm64 RyuJIT AdvSIMD + + +``` +| Method | Mean | Error | Ratio | RatioSD | Alloc Ratio | +|---------------------- |-----:|------:|------:|--------:|------------:| +| DefaultBindings | NA | NA | ? | ? | ? | +| DefaultBindingsMarkup | NA | NA | ? | ? | ? | +| TypedBindingsMarkup | NA | NA | ? | ? | ? | + +Benchmarks with issues: + ExecuteBindings.DefaultBindings: DefaultJob + ExecuteBindings.DefaultBindingsMarkup: DefaultJob + ExecuteBindings.TypedBindingsMarkup: DefaultJob diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report.csv b/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report.csv new file mode 100644 index 00000000..2cf1eb5a --- /dev/null +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report.csv @@ -0,0 +1,4 @@ +Method,Job,AnalyzeLaunchVariance,EvaluateOverhead,MaxAbsoluteError,MaxRelativeError,MinInvokeCount,MinIterationTime,OutlierMode,Affinity,EnvironmentVariables,Jit,LargeAddressAware,Platform,PowerPlanMode,Runtime,AllowVeryLargeObjects,Concurrent,CpuGroups,Force,HeapAffinitizeMask,HeapCount,NoAffinitize,RetainVm,Server,Arguments,BuildConfiguration,Clock,EngineFactory,NuGetReferences,Toolchain,IsMutator,InvocationCount,IterationCount,IterationTime,LaunchCount,MaxIterationCount,MaxWarmupIterationCount,MemoryRandomization,MinIterationCount,MinWarmupIterationCount,RunStrategy,UnrollFactor,WarmupCount,Mean,Error,Ratio,RatioSD,Alloc Ratio +DefaultBindings,DefaultJob,False,Default,Default,Default,Default,Default,Default,000000000000,Empty,RyuJit,Default,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,NA,NA,?,?,? +DefaultBindingsMarkup,DefaultJob,False,Default,Default,Default,Default,Default,Default,000000000000,Empty,RyuJit,Default,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,NA,NA,?,?,? +TypedBindingsMarkup,DefaultJob,False,Default,Default,Default,Default,Default,Default,000000000000,Empty,RyuJit,Default,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,NA,NA,?,?,? diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report.html b/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report.html new file mode 100644 index 00000000..8015c80b --- /dev/null +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report.html @@ -0,0 +1,31 @@ + + + + +CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-20240619-153708 + + + + +

+BenchmarkDotNet v0.13.12, macOS Sonoma 14.5 (23F79) [Darwin 23.5.0]
+Apple M2 Max, 1 CPU, 12 logical and 12 physical cores
+.NET SDK 8.0.302
+  [Host] : .NET 8.0.6 (8.0.624.26715), Arm64 RyuJIT AdvSIMD
+
+
+ + + + + + + +
Method MeanErrorRatioRatioSDAlloc Ratio
DefaultBindingsNANA???
DefaultBindingsMarkupNANA???
TypedBindingsMarkupNANA???
+ + diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report-github.md b/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report-github.md new file mode 100644 index 00000000..58814e84 --- /dev/null +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report-github.md @@ -0,0 +1,15 @@ +``` + +BenchmarkDotNet v0.13.12, macOS Sonoma 14.5 (23F79) [Darwin 23.5.0] +Apple M2 Max, 1 CPU, 12 logical and 12 physical cores +.NET SDK 8.0.302 + [Host] : .NET 8.0.6 (8.0.624.26715), Arm64 RyuJIT AdvSIMD + DefaultJob : .NET 8.0.6 (8.0.624.26715), Arm64 RyuJIT AdvSIMD + + +``` +| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Gen1 | Gen2 | Allocated | Alloc Ratio | +|---------------------- |----------:|----------:|----------:|------:|--------:|-------:|-------:|-------:|----------:|------------:| +| DefaultBindings | 2.493 μs | 0.0142 μs | 0.0126 μs | 1.00 | 0.00 | 0.2708 | 0.1335 | - | 2.22 KB | 1.00 | +| DefaultBindingsMarkup | 2.494 μs | 0.0101 μs | 0.0085 μs | 1.00 | 0.01 | 0.2708 | 0.1335 | - | 2.22 KB | 1.00 | +| TypedBindingsMarkup | 32.235 μs | 0.3598 μs | 0.3366 μs | 12.95 | 0.15 | 1.3428 | 0.6714 | 0.0610 | 11.13 KB | 5.02 | diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report.csv b/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report.csv new file mode 100644 index 00000000..87a93a70 --- /dev/null +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report.csv @@ -0,0 +1,4 @@ +Method,Job,AnalyzeLaunchVariance,EvaluateOverhead,MaxAbsoluteError,MaxRelativeError,MinInvokeCount,MinIterationTime,OutlierMode,Affinity,EnvironmentVariables,Jit,LargeAddressAware,Platform,PowerPlanMode,Runtime,AllowVeryLargeObjects,Concurrent,CpuGroups,Force,HeapAffinitizeMask,HeapCount,NoAffinitize,RetainVm,Server,Arguments,BuildConfiguration,Clock,EngineFactory,NuGetReferences,Toolchain,IsMutator,InvocationCount,IterationCount,IterationTime,LaunchCount,MaxIterationCount,MaxWarmupIterationCount,MemoryRandomization,MinIterationCount,MinWarmupIterationCount,RunStrategy,UnrollFactor,WarmupCount,Mean,Error,StdDev,Ratio,RatioSD,Gen0,Gen1,Gen2,Allocated,Alloc Ratio +DefaultBindings,DefaultJob,False,Default,Default,Default,Default,Default,Default,000000000000,Empty,RyuJit,Default,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,2.493 μs,0.0142 μs,0.0126 μs,1.00,0.00,0.2708,0.1335,0.0000,2.22 KB,1.00 +DefaultBindingsMarkup,DefaultJob,False,Default,Default,Default,Default,Default,Default,000000000000,Empty,RyuJit,Default,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,2.494 μs,0.0101 μs,0.0085 μs,1.00,0.01,0.2708,0.1335,0.0000,2.22 KB,1.00 +TypedBindingsMarkup,DefaultJob,False,Default,Default,Default,Default,Default,Default,000000000000,Empty,RyuJit,Default,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,32.235 μs,0.3598 μs,0.3366 μs,12.95,0.15,1.3428,0.6714,0.0610,11.13 KB,5.02 diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report.html b/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report.html new file mode 100644 index 00000000..a1aace07 --- /dev/null +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report.html @@ -0,0 +1,32 @@ + + + + +CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-20240619-154356 + + + + +

+BenchmarkDotNet v0.13.12, macOS Sonoma 14.5 (23F79) [Darwin 23.5.0]
+Apple M2 Max, 1 CPU, 12 logical and 12 physical cores
+.NET SDK 8.0.302
+  [Host]     : .NET 8.0.6 (8.0.624.26715), Arm64 RyuJIT AdvSIMD
+  DefaultJob : .NET 8.0.6 (8.0.624.26715), Arm64 RyuJIT AdvSIMD
+
+
+ + + + + + + +
Method MeanErrorStdDevRatioRatioSDGen0Gen1Gen2AllocatedAlloc Ratio
DefaultBindings2.493 μs0.0142 μs0.0126 μs1.000.000.27080.1335-2.22 KB1.00
DefaultBindingsMarkup2.494 μs0.0101 μs0.0085 μs1.000.010.27080.1335-2.22 KB1.00
TypedBindingsMarkup32.235 μs0.3598 μs0.3366 μs12.950.151.34280.67140.061011.13 KB5.02
+ + diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindings.cs b/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindings.cs new file mode 100644 index 00000000..e35f24ba --- /dev/null +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindings.cs @@ -0,0 +1,64 @@ +using BenchmarkDotNet.Attributes; +using CommunityToolkit.Maui.Markup.Benchmarks.Extensions; + +namespace CommunityToolkit.Maui.Markup.Benchmarks; + +[MemoryDiagnoser] +public class ExecuteBindings : BaseTest +{ + const string helloWorldText = "Hello World"; + + readonly LabelViewModel defaultBindingsLabelViewModel = new(); + readonly LabelViewModel defaultMarkupBindingsLabelViewModel = new(); + readonly LabelViewModel typedMarkupBindingsLabelViewModel = new(); + + readonly Label defaultBindingsLabel, defaultMarkupBindingsLabel, typedMarkupBindingsLabel; + + public ExecuteBindings() + { + defaultBindingsLabel = new() + { + BindingContext = defaultBindingsLabelViewModel + }; + defaultBindingsLabel.SetBinding(Label.TextProperty, nameof(LabelViewModel.Text)); + defaultBindingsLabel.SetBinding(Label.TextColorProperty, nameof(LabelViewModel.TextColor)); + defaultBindingsLabel.EnableAnimations(); + + defaultMarkupBindingsLabel = new Label + { + BindingContext = defaultMarkupBindingsLabelViewModel + }.Bind(Label.TextProperty, nameof(LabelViewModel.Text)) + .Bind(Label.TextColorProperty, nameof(LabelViewModel.TextColor)); + defaultMarkupBindingsLabel.EnableAnimations(); + + typedMarkupBindingsLabel = new Label + { + BindingContext = typedMarkupBindingsLabelViewModel + }.Bind(Label.TextProperty, + getter: (LabelViewModel vm) => vm.Text) + .Bind(Label.TextColorProperty, + getter: (LabelViewModel vm) => vm.TextColor); + typedMarkupBindingsLabel.EnableAnimations(); + } + + [Benchmark(Baseline = true)] + public void DefaultBindings() + { + defaultBindingsLabelViewModel.TextColor = Colors.Green; + defaultBindingsLabelViewModel.Text = helloWorldText; + } + + [Benchmark] + public void DefaultBindingsMarkup() + { + defaultMarkupBindingsLabelViewModel.TextColor = Colors.Green; + defaultMarkupBindingsLabelViewModel.Text = helloWorldText; + } + + [Benchmark] + public void TypedBindingsMarkup() + { + typedMarkupBindingsLabelViewModel.TextColor = Colors.Green; + typedMarkupBindingsLabelViewModel.Text = helloWorldText; + } +} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/InitializeBindings.cs b/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/InitializeBindings.cs new file mode 100644 index 00000000..7e756f07 --- /dev/null +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/InitializeBindings.cs @@ -0,0 +1,47 @@ +using BenchmarkDotNet.Attributes; + +namespace CommunityToolkit.Maui.Markup.Benchmarks; + +[MemoryDiagnoser] +public class InitializeBindings : BaseTest +{ + readonly Label defaultBindingsLabel = new() + { + BindingContext = new LabelViewModel() + }; + + readonly Label defaultMarkupBindingsLabel = new() + { + BindingContext = new LabelViewModel() + }; + + readonly Label typedMarkupBindingsLabel = new() + { + BindingContext = new LabelViewModel() + }; + + [Benchmark(Baseline = true)] + public void DefaultBindings() + { + defaultBindingsLabel.SetBinding(Label.TextProperty, nameof(LabelViewModel.Text)); + defaultBindingsLabel.SetBinding(Label.TextColorProperty, nameof(LabelViewModel.TextColor)); + } + + [Benchmark] + public void DefaultBindingsMarkup() + { + defaultMarkupBindingsLabel + .Bind(Label.TextProperty, nameof(LabelViewModel.Text)) + .Bind(Label.TextColorProperty, nameof(LabelViewModel.TextColor)); + } + + [Benchmark] + public void TypedBindingsMarkup() + { + typedMarkupBindingsLabel + .Bind(Label.TextProperty, + getter: (LabelViewModel vm) => vm.Text) + .Bind(Label.TextColorProperty, + getter: (LabelViewModel vm) => vm.TextColor); + } +} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/CommunityToolkit.Maui.Markup.Benchmarks.csproj b/src/CommunityToolkit.Maui.Markup.Benchmarks/CommunityToolkit.Maui.Markup.Benchmarks.csproj new file mode 100644 index 00000000..00b746f9 --- /dev/null +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/CommunityToolkit.Maui.Markup.Benchmarks.csproj @@ -0,0 +1,31 @@ + + + $(NetVersion) + true + Exe + false + + + + AnyCPU + pdbonly + true + true + true + Release + false + + + + + + + + + + + + + + + diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/Extensions/AnimationExtensions.cs b/src/CommunityToolkit.Maui.Markup.Benchmarks/Extensions/AnimationExtensions.cs new file mode 100644 index 00000000..98b53db8 --- /dev/null +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/Extensions/AnimationExtensions.cs @@ -0,0 +1,148 @@ +using CommunityToolkit.Maui.Markup.Benchmarks.Mocks; +using Microsoft.Maui.Animations; +using Microsoft.Maui.Handlers; + +namespace CommunityToolkit.Maui.Markup.Benchmarks.Extensions; + +static class AnimationExtensions +{ + public static void EnableAnimations(this IView view) => MockAnimationHandler.Prepare(view); + + // Inspired by Microsoft.Maui.Controls.Core.UnitTests.AnimationReadyHandler + class MockAnimationHandler : ViewHandler + { + MockAnimationHandler(IAnimationManager animationManager) : base(new PropertyMapper()) + { + SetMauiContext(new AnimationEnabledMauiContext(animationManager)); + } + + MockAnimationHandler() : this(new TestAnimationManager(new AsyncTicker())) + { + } + + public IAnimationManager? AnimationManager => ((AnimationEnabledMauiContext?)MauiContext)?.AnimationManager; + + public static T Prepare(T view) where T : IView + { + view.Handler = new MockAnimationHandler(); + + return view; + } + + protected override object CreatePlatformView() => new(); + + class AnimationEnabledMauiContext(IAnimationManager manager) : IMauiContext, IServiceProvider + { + public IServiceProvider Services => this; + + public IAnimationManager AnimationManager { get; } = manager; + + IMauiHandlersFactory IMauiContext.Handlers => throw new NotSupportedException(); + + public object GetService(Type serviceType) + { + if (serviceType == typeof(IAnimationManager)) + { + return AnimationManager; + } + + if (serviceType == typeof(IDispatcher)) + { + return new MockDispatcherProvider().GetForCurrentThread(); + } + + throw new NotSupportedException(); + } + } + + sealed class AsyncTicker : Ticker, IDisposable + { + CancellationTokenSource? cancellationTokenSource; + + public override async void Start() + { + cancellationTokenSource = new(); + + while (!cancellationTokenSource.IsCancellationRequested) + { + Fire?.Invoke(); + + if (!cancellationTokenSource.IsCancellationRequested) + { + await Task.Delay(TimeSpan.FromMilliseconds(16)); + } + } + } + + public override void Stop() => cancellationTokenSource?.Cancel(); + + public void Dispose() + { + cancellationTokenSource?.Dispose(); + } + } + + class TestAnimationManager : IAnimationManager + { + readonly List animations = []; + + public TestAnimationManager(ITicker ticker) + { + Ticker = ticker; + Ticker.Fire = OnFire; + } + + public double SpeedModifier { get; set; } = 1; + + public bool AutoStartTicker { get; set; } = false; + + public ITicker Ticker { get; } + + public void Add(Microsoft.Maui.Animations.Animation animation) + { + animations.Add(animation); + if (AutoStartTicker && !Ticker.IsRunning) + { + Ticker.Start(); + } + } + + public void Remove(Microsoft.Maui.Animations.Animation animation) + { + animations.Remove(animation); + if (!animations.Any()) + { + Ticker.Stop(); + } + } + + void OnFire() + { + var animations = this.animations.ToList(); + animations.ForEach(AnimationTick); + + if (!this.animations.Any()) + { + Ticker.Stop(); + } + + void AnimationTick(Microsoft.Maui.Animations.Animation animation) + { + if (animation.HasFinished) + { + this.animations.Remove(animation); + animation.RemoveFromParent(); + return; + } + + animation.Tick(16); + if (animation.HasFinished) + { + this.animations.Remove(animation); + animation.RemoveFromParent(); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/LabelViewModel.cs b/src/CommunityToolkit.Maui.Markup.Benchmarks/LabelViewModel.cs new file mode 100644 index 00000000..5b63671f --- /dev/null +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/LabelViewModel.cs @@ -0,0 +1,12 @@ +using CommunityToolkit.Mvvm.ComponentModel; + +namespace CommunityToolkit.Maui.Markup.Benchmarks; + +partial class LabelViewModel : ObservableObject +{ + [ObservableProperty] + string text = string.Empty; + + [ObservableProperty] + Color textColor = Colors.Black; +} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/Mocks/HandlerContextStub.cs b/src/CommunityToolkit.Maui.Markup.Benchmarks/Mocks/HandlerContextStub.cs new file mode 100644 index 00000000..40e35964 --- /dev/null +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/Mocks/HandlerContextStub.cs @@ -0,0 +1,19 @@ +namespace CommunityToolkit.Maui.Markup.Benchmarks.Mocks; + +using Microsoft.Maui.Animations; + +class HandlersContextStub : IMauiContext +{ + public HandlersContextStub(IServiceProvider services) + { + Services = services; + Handlers = Services.GetRequiredService(); + AnimationManager = services.GetService() ?? throw new NullReferenceException(); + } + + public IServiceProvider Services { get; } + + public IMauiHandlersFactory Handlers { get; } + + public IAnimationManager AnimationManager { get; } +} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/Mocks/MockApplication.cs b/src/CommunityToolkit.Maui.Markup.Benchmarks/Mocks/MockApplication.cs new file mode 100644 index 00000000..1982dbc3 --- /dev/null +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/Mocks/MockApplication.cs @@ -0,0 +1,21 @@ +namespace CommunityToolkit.Maui.Markup.Benchmarks.Mocks; + +using Microsoft.Maui.Handlers; + +class MockApplication(IServiceProvider serviceProvider) : Application, IPlatformApplication +{ + public new Application? Current = null; + public IServiceProvider Services { get; } = serviceProvider; + public IApplication Application => this; +} + +// Inspired by https://github.com/dotnet/maui/blob/main/src/Controls/tests/Core.UnitTests/TestClasses/ApplicationHandlerStub.cs +class ApplicationHandlerStub() : ElementHandler(Mapper) +{ + public static IPropertyMapper Mapper = new PropertyMapper(ElementMapper); + + protected override object CreatePlatformElement() + { + return new object(); + } +} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/Mocks/MockDispatcherProvider.cs b/src/CommunityToolkit.Maui.Markup.Benchmarks/Mocks/MockDispatcherProvider.cs new file mode 100644 index 00000000..1f072386 --- /dev/null +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/Mocks/MockDispatcherProvider.cs @@ -0,0 +1,71 @@ +namespace CommunityToolkit.Maui.Markup.Benchmarks.Mocks; + +// Inspired by https://github.com/dotnet/maui/blob/main/src/Core/tests/UnitTests/TestClasses/DispatcherStub.cs +sealed class MockDispatcherProvider : IDispatcherProvider, IDisposable +{ + static readonly DispatcherMock dispatcherMock = new(); + + readonly ThreadLocal dispatcherInstance = new(() => dispatcherMock); + + public IDispatcher GetForCurrentThread() => dispatcherInstance.Value ?? throw new InvalidOperationException(); + + void IDisposable.Dispose() => dispatcherInstance.Dispose(); + + sealed class DispatcherMock : IDispatcher + { + public bool IsDispatchRequired => false; + + public int ManagedThreadId { get; } = Environment.CurrentManagedThreadId; + + public IDispatcherTimer CreateTimer() + { + return new DispatcherTimerStub(this); + } + + public bool Dispatch(Action action) + { + action(); + + return true; + } + + public bool DispatchDelayed(TimeSpan delay, Action action) + { + return false; + } + } + + sealed class DispatcherTimerStub(DispatcherMock dispatcher) : IDispatcherTimer, IDisposable + { + Timer? timer; + + public TimeSpan Interval { get; set; } + + public bool IsRepeating { get; set; } + + public bool IsRunning => timer != null; + + public event EventHandler? Tick; + + public void Start() + { + timer = new Timer(OnTimeout, null, Interval, IsRepeating ? Interval : Timeout.InfiniteTimeSpan); + + void OnTimeout(object? state) + { + dispatcher.Dispatch(() => Tick?.Invoke(this, EventArgs.Empty)); + } + } + + public void Stop() + { + Dispose(); + } + + public void Dispose() + { + timer?.Dispose(); + timer = null; + } + } +} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/Program.cs b/src/CommunityToolkit.Maui.Markup.Benchmarks/Program.cs new file mode 100644 index 00000000..dd2c5ecf --- /dev/null +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/Program.cs @@ -0,0 +1,13 @@ +using BenchmarkDotNet.Configs; +using BenchmarkDotNet.Running; +namespace CommunityToolkit.Maui.Markup.Benchmarks; + +public class Program +{ + public static void Main(string[] args) + { + var config = DefaultConfig.Instance; + BenchmarkRunner.Run(config, args); + BenchmarkRunner.Run(config, args); + } +} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Markup.UnitTests/Mocks/MockDispatcherProvider.cs b/src/CommunityToolkit.Maui.Markup.UnitTests/Mocks/MockDispatcherProvider.cs index 21fd3a98..f5be73ea 100644 --- a/src/CommunityToolkit.Maui.Markup.UnitTests/Mocks/MockDispatcherProvider.cs +++ b/src/CommunityToolkit.Maui.Markup.UnitTests/Mocks/MockDispatcherProvider.cs @@ -1,8 +1,4 @@ -using System; -using System.Threading; -using Microsoft.Maui.Dispatching; - -namespace CommunityToolkit.Maui.Markup.UnitTests.Mocks; +namespace CommunityToolkit.Maui.Markup.UnitTests.Mocks; // Inspired by https://github.com/dotnet/maui/blob/main/src/Core/tests/UnitTests/TestClasses/DispatcherStub.cs sealed class MockDispatcherProvider : IDispatcherProvider, IDisposable @@ -17,11 +13,9 @@ sealed class MockDispatcherProvider : IDispatcherProvider, IDisposable sealed class DispatcherMock : IDispatcher { - public DispatcherMock() => ManagedThreadId = Environment.CurrentManagedThreadId; - public bool IsDispatchRequired => false; - public int ManagedThreadId { get; } + public int ManagedThreadId { get; } = Environment.CurrentManagedThreadId; public IDispatcherTimer CreateTimer() => throw new NotImplementedException(); @@ -33,6 +27,5 @@ public bool Dispatch(Action action) return true; } - } } \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Markup.sln b/src/CommunityToolkit.Maui.Markup.sln index c4dced19..044c1144 100644 --- a/src/CommunityToolkit.Maui.Markup.sln +++ b/src/CommunityToolkit.Maui.Markup.sln @@ -16,6 +16,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Maui.Markup.SourceGenerators", "CommunityToolkit.Maui.Markup.SourceGenerators\CommunityToolkit.Maui.Markup.SourceGenerators.csproj", "{C66CEA39-565E-479C-974D-72795D3502CB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Maui.Markup.Benchmarks", "CommunityToolkit.Maui.Markup.Benchmarks\CommunityToolkit.Maui.Markup.Benchmarks.csproj", "{9A46B6CE-CC4B-4F26-80F8-779C94A88C18}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -34,6 +36,10 @@ Global {C66CEA39-565E-479C-974D-72795D3502CB}.Debug|Any CPU.Build.0 = Debug|Any CPU {C66CEA39-565E-479C-974D-72795D3502CB}.Release|Any CPU.ActiveCfg = Release|Any CPU {C66CEA39-565E-479C-974D-72795D3502CB}.Release|Any CPU.Build.0 = Release|Any CPU + {9A46B6CE-CC4B-4F26-80F8-779C94A88C18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9A46B6CE-CC4B-4F26-80F8-779C94A88C18}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9A46B6CE-CC4B-4F26-80F8-779C94A88C18}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9A46B6CE-CC4B-4F26-80F8-779C94A88C18}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 6f6b9315b4f3c5c6ba78d991db2c2d34b0ac00e7 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Wed, 19 Jun 2024 15:56:00 -0700 Subject: [PATCH 02/25] Add `BenchmarkDotNet.Artifacts/` to `.gitignore` --- .gitignore | 3 ++ ...enchmarks.ExecuteBindings-report-github.md | 19 ----------- ...rkup.Benchmarks.ExecuteBindings-report.csv | 4 --- ...kup.Benchmarks.ExecuteBindings-report.html | 31 ------------------ ...hmarks.InitializeBindings-report-github.md | 15 --------- ...p.Benchmarks.InitializeBindings-report.csv | 4 --- ....Benchmarks.InitializeBindings-report.html | 32 ------------------- 7 files changed, 3 insertions(+), 105 deletions(-) delete mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report-github.md delete mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report.csv delete mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report.html delete mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report-github.md delete mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report.csv delete mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report.html diff --git a/.gitignore b/.gitignore index d9701cbd..c2566e27 100644 --- a/.gitignore +++ b/.gitignore @@ -671,6 +671,9 @@ hs_err_pid* # MFractor .mfractor/ +# Benchmarkdot +BenchmarkDotNet.Artifacts/ + ### VisualStudio ### ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report-github.md b/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report-github.md deleted file mode 100644 index 561a2bd8..00000000 --- a/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report-github.md +++ /dev/null @@ -1,19 +0,0 @@ -``` - -BenchmarkDotNet v0.13.12, macOS Sonoma 14.5 (23F79) [Darwin 23.5.0] -Apple M2 Max, 1 CPU, 12 logical and 12 physical cores -.NET SDK 8.0.302 - [Host] : .NET 8.0.6 (8.0.624.26715), Arm64 RyuJIT AdvSIMD - - -``` -| Method | Mean | Error | Ratio | RatioSD | Alloc Ratio | -|---------------------- |-----:|------:|------:|--------:|------------:| -| DefaultBindings | NA | NA | ? | ? | ? | -| DefaultBindingsMarkup | NA | NA | ? | ? | ? | -| TypedBindingsMarkup | NA | NA | ? | ? | ? | - -Benchmarks with issues: - ExecuteBindings.DefaultBindings: DefaultJob - ExecuteBindings.DefaultBindingsMarkup: DefaultJob - ExecuteBindings.TypedBindingsMarkup: DefaultJob diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report.csv b/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report.csv deleted file mode 100644 index 2cf1eb5a..00000000 --- a/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report.csv +++ /dev/null @@ -1,4 +0,0 @@ -Method,Job,AnalyzeLaunchVariance,EvaluateOverhead,MaxAbsoluteError,MaxRelativeError,MinInvokeCount,MinIterationTime,OutlierMode,Affinity,EnvironmentVariables,Jit,LargeAddressAware,Platform,PowerPlanMode,Runtime,AllowVeryLargeObjects,Concurrent,CpuGroups,Force,HeapAffinitizeMask,HeapCount,NoAffinitize,RetainVm,Server,Arguments,BuildConfiguration,Clock,EngineFactory,NuGetReferences,Toolchain,IsMutator,InvocationCount,IterationCount,IterationTime,LaunchCount,MaxIterationCount,MaxWarmupIterationCount,MemoryRandomization,MinIterationCount,MinWarmupIterationCount,RunStrategy,UnrollFactor,WarmupCount,Mean,Error,Ratio,RatioSD,Alloc Ratio -DefaultBindings,DefaultJob,False,Default,Default,Default,Default,Default,Default,000000000000,Empty,RyuJit,Default,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,NA,NA,?,?,? -DefaultBindingsMarkup,DefaultJob,False,Default,Default,Default,Default,Default,Default,000000000000,Empty,RyuJit,Default,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,NA,NA,?,?,? -TypedBindingsMarkup,DefaultJob,False,Default,Default,Default,Default,Default,Default,000000000000,Empty,RyuJit,Default,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,NA,NA,?,?,? diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report.html b/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report.html deleted file mode 100644 index 8015c80b..00000000 --- a/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-report.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - -CommunityToolkit.Maui.Markup.Benchmarks.ExecuteBindings-20240619-153708 - - - - -

-BenchmarkDotNet v0.13.12, macOS Sonoma 14.5 (23F79) [Darwin 23.5.0]
-Apple M2 Max, 1 CPU, 12 logical and 12 physical cores
-.NET SDK 8.0.302
-  [Host] : .NET 8.0.6 (8.0.624.26715), Arm64 RyuJIT AdvSIMD
-
-
- - - - - - - -
Method MeanErrorRatioRatioSDAlloc Ratio
DefaultBindingsNANA???
DefaultBindingsMarkupNANA???
TypedBindingsMarkupNANA???
- - diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report-github.md b/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report-github.md deleted file mode 100644 index 58814e84..00000000 --- a/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report-github.md +++ /dev/null @@ -1,15 +0,0 @@ -``` - -BenchmarkDotNet v0.13.12, macOS Sonoma 14.5 (23F79) [Darwin 23.5.0] -Apple M2 Max, 1 CPU, 12 logical and 12 physical cores -.NET SDK 8.0.302 - [Host] : .NET 8.0.6 (8.0.624.26715), Arm64 RyuJIT AdvSIMD - DefaultJob : .NET 8.0.6 (8.0.624.26715), Arm64 RyuJIT AdvSIMD - - -``` -| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Gen1 | Gen2 | Allocated | Alloc Ratio | -|---------------------- |----------:|----------:|----------:|------:|--------:|-------:|-------:|-------:|----------:|------------:| -| DefaultBindings | 2.493 μs | 0.0142 μs | 0.0126 μs | 1.00 | 0.00 | 0.2708 | 0.1335 | - | 2.22 KB | 1.00 | -| DefaultBindingsMarkup | 2.494 μs | 0.0101 μs | 0.0085 μs | 1.00 | 0.01 | 0.2708 | 0.1335 | - | 2.22 KB | 1.00 | -| TypedBindingsMarkup | 32.235 μs | 0.3598 μs | 0.3366 μs | 12.95 | 0.15 | 1.3428 | 0.6714 | 0.0610 | 11.13 KB | 5.02 | diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report.csv b/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report.csv deleted file mode 100644 index 87a93a70..00000000 --- a/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report.csv +++ /dev/null @@ -1,4 +0,0 @@ -Method,Job,AnalyzeLaunchVariance,EvaluateOverhead,MaxAbsoluteError,MaxRelativeError,MinInvokeCount,MinIterationTime,OutlierMode,Affinity,EnvironmentVariables,Jit,LargeAddressAware,Platform,PowerPlanMode,Runtime,AllowVeryLargeObjects,Concurrent,CpuGroups,Force,HeapAffinitizeMask,HeapCount,NoAffinitize,RetainVm,Server,Arguments,BuildConfiguration,Clock,EngineFactory,NuGetReferences,Toolchain,IsMutator,InvocationCount,IterationCount,IterationTime,LaunchCount,MaxIterationCount,MaxWarmupIterationCount,MemoryRandomization,MinIterationCount,MinWarmupIterationCount,RunStrategy,UnrollFactor,WarmupCount,Mean,Error,StdDev,Ratio,RatioSD,Gen0,Gen1,Gen2,Allocated,Alloc Ratio -DefaultBindings,DefaultJob,False,Default,Default,Default,Default,Default,Default,000000000000,Empty,RyuJit,Default,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,2.493 μs,0.0142 μs,0.0126 μs,1.00,0.00,0.2708,0.1335,0.0000,2.22 KB,1.00 -DefaultBindingsMarkup,DefaultJob,False,Default,Default,Default,Default,Default,Default,000000000000,Empty,RyuJit,Default,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,2.494 μs,0.0101 μs,0.0085 μs,1.00,0.01,0.2708,0.1335,0.0000,2.22 KB,1.00 -TypedBindingsMarkup,DefaultJob,False,Default,Default,Default,Default,Default,Default,000000000000,Empty,RyuJit,Default,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 8.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,32.235 μs,0.3598 μs,0.3366 μs,12.95,0.15,1.3428,0.6714,0.0610,11.13 KB,5.02 diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report.html b/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report.html deleted file mode 100644 index a1aace07..00000000 --- a/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts/results/CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-report.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - -CommunityToolkit.Maui.Markup.Benchmarks.InitializeBindings-20240619-154356 - - - - -

-BenchmarkDotNet v0.13.12, macOS Sonoma 14.5 (23F79) [Darwin 23.5.0]
-Apple M2 Max, 1 CPU, 12 logical and 12 physical cores
-.NET SDK 8.0.302
-  [Host]     : .NET 8.0.6 (8.0.624.26715), Arm64 RyuJIT AdvSIMD
-  DefaultJob : .NET 8.0.6 (8.0.624.26715), Arm64 RyuJIT AdvSIMD
-
-
- - - - - - - -
Method MeanErrorStdDevRatioRatioSDGen0Gen1Gen2AllocatedAlloc Ratio
DefaultBindings2.493 μs0.0142 μs0.0126 μs1.000.000.27080.1335-2.22 KB1.00
DefaultBindingsMarkup2.494 μs0.0101 μs0.0085 μs1.000.010.27080.1335-2.22 KB1.00
TypedBindingsMarkup32.235 μs0.3598 μs0.3366 μs12.950.151.34280.67140.061011.13 KB5.02
- - From f6eb04cb890f479edae534d190c0a86768612464 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:02:01 -0700 Subject: [PATCH 03/25] Add Benchmarks to Build Pipeline --- azure-pipelines.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f82d04fe..842fd2e2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -10,6 +10,7 @@ variables: PathToCommunityToolkitCsproj: 'src/CommunityToolkit.Maui.Markup/CommunityToolkit.Maui.Markup.csproj' PathToCommunityToolkitSampleCsproj: 'samples/CommunityToolkit.Maui.Markup.Sample/CommunityToolkit.Maui.Markup.Sample.csproj' PathToCommunityToolkitUnitTestCsproj: 'src/CommunityToolkit.Maui.Markup.UnitTests/CommunityToolkit.Maui.Markup.UnitTests.csproj' + PathToCommunityToolkitBenchmarkCsproj: 'src/CommunityToolkit.Maui.Markup.Benchmarks/CommunityToolkit.Maui.Markup.Benchmarks.csproj' PathToCommunityToolkitSourceGeneratorsCsproj: 'src/CommunityToolkit.Maui.Markup.SourceGenerators/CommunityToolkit.Maui.Markup.SourceGenerators.csproj' XcodeVersion: '15.2.0' ShouldCheckDependencies: true @@ -42,7 +43,7 @@ schedules: - main jobs: - - job: build_sample + - job: build_library displayName: Build Library strategy: matrix: @@ -131,6 +132,13 @@ jobs: inputs: script: 'dotnet test -c Release $(PathToCommunityToolkitUnitTestCsproj) --settings ".runsettings" --collect "XPlat code coverage" --logger trx --results-directory $(Agent.TempDirectory)' + - task: DotNetCoreCLI@2 + displayName: 'Run Benchmarks' + inputs: + command: 'custom' + custom: 'run' + arguments: '--project $(PathToCommunityToolkitBenchmarkCsproj) --configuration Release' + - task: PublishTestResults@2 condition: eq(variables['Agent.OS'], 'Windows_NT') # Only run this step on Windows displayName: 'Publish Test Results' @@ -147,6 +155,12 @@ jobs: summaryFileLocation: '$(Agent.TempDirectory)/**/coverage.cobertura.xml' failIfCoverageEmpty: true + - task: PublishPipelineArtifact@1 + inputs: + targetPath: '$(Build.SourcesDirectory)/artifacts/BenchmarkDotNet.Artifacts' + artifact: 'benchmark-results' + publishLocation: 'pipeline' + # pack - task: CmdLine@2 displayName: 'Build and Pack CommunityToolkit.Maui.Markup' From 242637380940e80f136a010f761d622998388c4a Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:02:26 -0700 Subject: [PATCH 04/25] Update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index c2566e27..85820e5a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ **/.vscode* +**/.meteor* + ### fastlane ### # fastlane - A streamlined workflow tool for Cocoa deployment From f60009b8e4af0e7d6d7d20dfdea615a9a664bcfb Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:17:36 -0700 Subject: [PATCH 05/25] Only publish artifacts on Windows --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 842fd2e2..a5806af1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -156,6 +156,7 @@ jobs: failIfCoverageEmpty: true - task: PublishPipelineArtifact@1 + condition: eq(variables['Agent.OS'], 'Windows_NT') # Only run this step on Windows inputs: targetPath: '$(Build.SourcesDirectory)/artifacts/BenchmarkDotNet.Artifacts' artifact: 'benchmark-results' From f7a11a684b6a9ad740879141f961db714eb2e4a6 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:18:04 -0700 Subject: [PATCH 06/25] Segregate View-to-ViewModel Bindings from ViewModel-To-View Bindings --- .../Benchmarks/ExecuteBindings.cs | 64 ------------------- .../Benchmarks/ExecuteBindingsBase.cs | 45 +++++++++++++ .../ExecuteBindings_ViewModelToView.cs | 28 ++++++++ .../ExecuteBindings_ViewToViewModel.cs | 28 ++++++++ .../Benchmarks/InitializeBindings.cs | 6 +- .../LabelViewModel.cs | 2 +- .../Program.cs | 5 +- 7 files changed, 109 insertions(+), 69 deletions(-) delete mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindings.cs create mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindingsBase.cs create mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindings_ViewModelToView.cs create mode 100644 src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindings_ViewToViewModel.cs diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindings.cs b/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindings.cs deleted file mode 100644 index e35f24ba..00000000 --- a/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindings.cs +++ /dev/null @@ -1,64 +0,0 @@ -using BenchmarkDotNet.Attributes; -using CommunityToolkit.Maui.Markup.Benchmarks.Extensions; - -namespace CommunityToolkit.Maui.Markup.Benchmarks; - -[MemoryDiagnoser] -public class ExecuteBindings : BaseTest -{ - const string helloWorldText = "Hello World"; - - readonly LabelViewModel defaultBindingsLabelViewModel = new(); - readonly LabelViewModel defaultMarkupBindingsLabelViewModel = new(); - readonly LabelViewModel typedMarkupBindingsLabelViewModel = new(); - - readonly Label defaultBindingsLabel, defaultMarkupBindingsLabel, typedMarkupBindingsLabel; - - public ExecuteBindings() - { - defaultBindingsLabel = new() - { - BindingContext = defaultBindingsLabelViewModel - }; - defaultBindingsLabel.SetBinding(Label.TextProperty, nameof(LabelViewModel.Text)); - defaultBindingsLabel.SetBinding(Label.TextColorProperty, nameof(LabelViewModel.TextColor)); - defaultBindingsLabel.EnableAnimations(); - - defaultMarkupBindingsLabel = new Label - { - BindingContext = defaultMarkupBindingsLabelViewModel - }.Bind(Label.TextProperty, nameof(LabelViewModel.Text)) - .Bind(Label.TextColorProperty, nameof(LabelViewModel.TextColor)); - defaultMarkupBindingsLabel.EnableAnimations(); - - typedMarkupBindingsLabel = new Label - { - BindingContext = typedMarkupBindingsLabelViewModel - }.Bind(Label.TextProperty, - getter: (LabelViewModel vm) => vm.Text) - .Bind(Label.TextColorProperty, - getter: (LabelViewModel vm) => vm.TextColor); - typedMarkupBindingsLabel.EnableAnimations(); - } - - [Benchmark(Baseline = true)] - public void DefaultBindings() - { - defaultBindingsLabelViewModel.TextColor = Colors.Green; - defaultBindingsLabelViewModel.Text = helloWorldText; - } - - [Benchmark] - public void DefaultBindingsMarkup() - { - defaultMarkupBindingsLabelViewModel.TextColor = Colors.Green; - defaultMarkupBindingsLabelViewModel.Text = helloWorldText; - } - - [Benchmark] - public void TypedBindingsMarkup() - { - typedMarkupBindingsLabelViewModel.TextColor = Colors.Green; - typedMarkupBindingsLabelViewModel.Text = helloWorldText; - } -} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindingsBase.cs b/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindingsBase.cs new file mode 100644 index 00000000..1b2c6482 --- /dev/null +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindingsBase.cs @@ -0,0 +1,45 @@ +using CommunityToolkit.Maui.Markup.Benchmarks.Extensions; + +namespace CommunityToolkit.Maui.Markup.Benchmarks; + +public abstract class ExecuteBindingsBase : BaseTest +{ + protected const string helloWorldText = "Hello World"; + + protected ExecuteBindingsBase() + { + DefaultBindingsLabel = new() + { + BindingContext = DefaultBindingsLabelViewModel + }; + DefaultBindingsLabel.SetBinding(Label.TextProperty, nameof(LabelViewModel.Text), mode: BindingMode.TwoWay); + DefaultBindingsLabel.SetBinding(Label.TextColorProperty, nameof(LabelViewModel.TextColor), mode: BindingMode.TwoWay); + DefaultBindingsLabel.EnableAnimations(); + + DefaultMarkupBindingsLabel = new Label + { + 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, + getter: (LabelViewModel vm) => vm.Text, + mode: BindingMode.TwoWay) + .Bind(Label.TextColorProperty, + getter: (LabelViewModel vm) => vm.TextColor, + 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; } +} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindings_ViewModelToView.cs b/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindings_ViewModelToView.cs new file mode 100644 index 00000000..1c76f474 --- /dev/null +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindings_ViewModelToView.cs @@ -0,0 +1,28 @@ +using BenchmarkDotNet.Attributes; + +namespace CommunityToolkit.Maui.Markup.Benchmarks; + +[MemoryDiagnoser] +public class ExecuteBindings_ViewModelToView : ExecuteBindingsBase +{ + [Benchmark(Baseline = true)] + public void ExecuteDefaultBindings_ViewModelToView() + { + DefaultBindingsLabelViewModel.TextColor = Colors.Green; + DefaultBindingsLabelViewModel.Text = helloWorldText; + } + + [Benchmark] + public void ExecuteDefaultBindingsMarkup_ViewModelToView() + { + DefaultMarkupBindingsLabelViewModel.TextColor = Colors.Green; + DefaultMarkupBindingsLabelViewModel.Text = helloWorldText; + } + + [Benchmark] + public void ExecuteTypedBindingsMarkup_ViewModelToView() + { + TypedMarkupBindingsLabelViewModel.TextColor = Colors.Green; + TypedMarkupBindingsLabelViewModel.Text = helloWorldText; + } +} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindings_ViewToViewModel.cs b/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindings_ViewToViewModel.cs new file mode 100644 index 00000000..9ec7a584 --- /dev/null +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindings_ViewToViewModel.cs @@ -0,0 +1,28 @@ +using BenchmarkDotNet.Attributes; + +namespace CommunityToolkit.Maui.Markup.Benchmarks; + +[MemoryDiagnoser] +public class ExecuteBindings_ViewToViewModel : ExecuteBindingsBase +{ + [Benchmark(Baseline = true)] + public void ExecuteDefaultBindings_ViewToViewModel() + { + DefaultBindingsLabel.TextColor = Colors.Green; + DefaultBindingsLabel.Text = helloWorldText; + } + + [Benchmark] + public void ExecuteDefaultBindingsMarkup_ViewToViewModel() + { + DefaultMarkupBindingsLabel.TextColor = Colors.Green; + DefaultMarkupBindingsLabel.Text = helloWorldText; + } + + [Benchmark] + public void ExecuteTypedBindingsMarkup_ViewToViewModel() + { + TypedMarkupBindingsLabel.TextColor = Colors.Green; + TypedMarkupBindingsLabel.Text = helloWorldText; + } +} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/InitializeBindings.cs b/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/InitializeBindings.cs index 7e756f07..9276f5db 100644 --- a/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/InitializeBindings.cs +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/InitializeBindings.cs @@ -21,14 +21,14 @@ public class InitializeBindings : BaseTest }; [Benchmark(Baseline = true)] - public void DefaultBindings() + public void InitializeDefaultBindings() { defaultBindingsLabel.SetBinding(Label.TextProperty, nameof(LabelViewModel.Text)); defaultBindingsLabel.SetBinding(Label.TextColorProperty, nameof(LabelViewModel.TextColor)); } [Benchmark] - public void DefaultBindingsMarkup() + public void InitializeDefaultBindingsMarkup() { defaultMarkupBindingsLabel .Bind(Label.TextProperty, nameof(LabelViewModel.Text)) @@ -36,7 +36,7 @@ public void DefaultBindingsMarkup() } [Benchmark] - public void TypedBindingsMarkup() + public void InitializeTypedBindingsMarkup() { typedMarkupBindingsLabel .Bind(Label.TextProperty, diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/LabelViewModel.cs b/src/CommunityToolkit.Maui.Markup.Benchmarks/LabelViewModel.cs index 5b63671f..a6a8d594 100644 --- a/src/CommunityToolkit.Maui.Markup.Benchmarks/LabelViewModel.cs +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/LabelViewModel.cs @@ -2,7 +2,7 @@ namespace CommunityToolkit.Maui.Markup.Benchmarks; -partial class LabelViewModel : ObservableObject +public partial class LabelViewModel : ObservableObject { [ObservableProperty] string text = string.Empty; diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/Program.cs b/src/CommunityToolkit.Maui.Markup.Benchmarks/Program.cs index dd2c5ecf..58bfa84d 100644 --- a/src/CommunityToolkit.Maui.Markup.Benchmarks/Program.cs +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/Program.cs @@ -1,5 +1,6 @@ using BenchmarkDotNet.Configs; using BenchmarkDotNet.Running; + namespace CommunityToolkit.Maui.Markup.Benchmarks; public class Program @@ -7,7 +8,9 @@ public class Program public static void Main(string[] args) { var config = DefaultConfig.Instance; + BenchmarkRunner.Run(config, args); - BenchmarkRunner.Run(config, args); + BenchmarkRunner.Run(config, args); + BenchmarkRunner.Run(config, args); } } \ No newline at end of file From 1098f16ff2a081a07d440e54f847126cb9e27114 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:41:51 -0700 Subject: [PATCH 07/25] Add missing setters --- .../Benchmarks/ExecuteBindingsBase.cs | 2 ++ .../Benchmarks/InitializeBindings.cs | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindingsBase.cs b/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindingsBase.cs index 1b2c6482..079e98cc 100644 --- a/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindingsBase.cs +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/ExecuteBindingsBase.cs @@ -28,9 +28,11 @@ protected ExecuteBindingsBase() BindingContext = TypedMarkupBindingsLabelViewModel }.Bind(Label.TextProperty, getter: (LabelViewModel vm) => vm.Text, + setter: (LabelViewModel vm, string text) => vm.Text = text, mode: BindingMode.TwoWay) .Bind(Label.TextColorProperty, getter: (LabelViewModel vm) => vm.TextColor, + setter: (LabelViewModel vm, Color textColor) => vm.TextColor = textColor, mode: BindingMode.TwoWay); TypedMarkupBindingsLabel.EnableAnimations(); } diff --git a/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/InitializeBindings.cs b/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/InitializeBindings.cs index 9276f5db..dc83d9ec 100644 --- a/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/InitializeBindings.cs +++ b/src/CommunityToolkit.Maui.Markup.Benchmarks/Benchmarks/InitializeBindings.cs @@ -23,16 +23,16 @@ public class InitializeBindings : BaseTest [Benchmark(Baseline = true)] public void InitializeDefaultBindings() { - defaultBindingsLabel.SetBinding(Label.TextProperty, nameof(LabelViewModel.Text)); - defaultBindingsLabel.SetBinding(Label.TextColorProperty, nameof(LabelViewModel.TextColor)); + 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)) - .Bind(Label.TextColorProperty, nameof(LabelViewModel.TextColor)); + .Bind(Label.TextProperty, nameof(LabelViewModel.Text), mode: BindingMode.TwoWay) + .Bind(Label.TextColorProperty, nameof(LabelViewModel.TextColor), mode: BindingMode.TwoWay); } [Benchmark] @@ -40,8 +40,12 @@ public void InitializeTypedBindingsMarkup() { typedMarkupBindingsLabel .Bind(Label.TextProperty, - getter: (LabelViewModel vm) => vm.Text) + getter: (LabelViewModel vm) => vm.Text, + setter: (LabelViewModel vm, string text) => vm.Text = text, + mode: BindingMode.TwoWay) .Bind(Label.TextColorProperty, - getter: (LabelViewModel vm) => vm.TextColor); + getter: (LabelViewModel vm) => vm.TextColor, + setter: (LabelViewModel vm, Color textColor) => vm.TextColor = textColor, + mode: BindingMode.TwoWay); } } \ No newline at end of file From 120f889662c26a1c2839d609e4d37494d9da5ddd Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:04:48 -0700 Subject: [PATCH 08/25] Update azure-pipelines.yml --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a5806af1..9c97f556 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -158,7 +158,7 @@ jobs: - task: PublishPipelineArtifact@1 condition: eq(variables['Agent.OS'], 'Windows_NT') # Only run this step on Windows inputs: - targetPath: '$(Build.SourcesDirectory)/artifacts/BenchmarkDotNet.Artifacts' + targetPath: '$(Build.SourcesDirectory)/**/BenchmarkDotNet.Artifacts' artifact: 'benchmark-results' publishLocation: 'pipeline' From 6c4afaaf824d723b895097bb82bb7e7f6a59f687 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:18:43 -0700 Subject: [PATCH 09/25] Update Pipeline Order + Display Name --- azure-pipelines.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9c97f556..4b0fa2b9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -132,13 +132,6 @@ jobs: inputs: script: 'dotnet test -c Release $(PathToCommunityToolkitUnitTestCsproj) --settings ".runsettings" --collect "XPlat code coverage" --logger trx --results-directory $(Agent.TempDirectory)' - - task: DotNetCoreCLI@2 - displayName: 'Run Benchmarks' - inputs: - command: 'custom' - custom: 'run' - arguments: '--project $(PathToCommunityToolkitBenchmarkCsproj) --configuration Release' - - task: PublishTestResults@2 condition: eq(variables['Agent.OS'], 'Windows_NT') # Only run this step on Windows displayName: 'Publish Test Results' @@ -155,8 +148,16 @@ jobs: summaryFileLocation: '$(Agent.TempDirectory)/**/coverage.cobertura.xml' failIfCoverageEmpty: true + - task: DotNetCoreCLI@2 + displayName: 'Run Benchmarks' + inputs: + command: 'custom' + custom: 'run' + arguments: '--project $(PathToCommunityToolkitBenchmarkCsproj) --configuration Release' + - task: PublishPipelineArtifact@1 condition: eq(variables['Agent.OS'], 'Windows_NT') # Only run this step on Windows + displayName: 'Publish Benchmark Artifacts' inputs: targetPath: '$(Build.SourcesDirectory)/**/BenchmarkDotNet.Artifacts' artifact: 'benchmark-results' From 9f6f5943404d957d3cfca1d3fc1fce8ceb311e5d Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:25:16 -0700 Subject: [PATCH 10/25] Move Benchmarks + Sample App to Separate Job Pipeline Running these in parallel optimizes our pipeline speeds --- azure-pipelines.yml | 126 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 105 insertions(+), 21 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4b0fa2b9..085c655f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -42,7 +42,54 @@ schedules: include: - main -jobs: +jobs: + - job: build_sample + displayName: Build Sample App + strategy: + matrix: + 'Windows': + image: 'windows-latest' + 'macOS': + image: 'macos-13' + pool: + vmImage: $(image) + steps: + - task: CmdLine@2 + displayName: 'Set Xcode v$(XcodeVersion)' + condition: eq(variables['Agent.OS'], 'Darwin') # Only run this step on macOS + inputs: + script: echo '##vso[task.setvariable variable=MD_APPLE_SDK_ROOT;]'/Applications/Xcode_$(XcodeVersion).app;sudo xcode-select --switch /Applications/Xcode_$(XcodeVersion).app/Contents/Developer + + - task: UseDotNet@2 + displayName: 'Install .NET SDK' + inputs: + packageType: 'sdk' + version: '$(NET_VERSION)' + includePreviewVersions: false + + - task: CmdLine@2 + displayName: 'Install .NET MAUI Workload' + inputs: + script : 'dotnet workload install maui' + + - pwsh: | + Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1' + .\workload-install.ps1 + displayName: Install Tizen Workload + + # Print Information on the .NET SDK Used By the CI Build Host + # These logs are useful information when debugging CI Builds + # Note: This step doesn't execute nor modify any code; it is strictly used for logging + debugging purposes + - task: CmdLine@2 + displayName: 'Display dotnet --info' + inputs: + script: dotnet --info + + - task: CmdLine@2 + displayName: 'Build CommunityToolkit.Maui.Markup.Sample' + inputs: + script: 'dotnet build -c Release $(PathToCommunityToolkitSampleCsproj)' + - job: build_library displayName: Build Library strategy: @@ -116,11 +163,6 @@ jobs: inputs: script: 'dotnet build -c Release $(PathToCommunityToolkitCsproj)' - - task: CmdLine@2 - displayName: 'Build CommunityToolkit.Maui.Markup.Sample' - inputs: - script: 'dotnet build -c Release $(PathToCommunityToolkitSampleCsproj)' - - task: CmdLine@2 displayName: 'Build CommunityToolkit.Maui.Markup.UnitTests' inputs: @@ -148,21 +190,6 @@ jobs: summaryFileLocation: '$(Agent.TempDirectory)/**/coverage.cobertura.xml' failIfCoverageEmpty: true - - task: DotNetCoreCLI@2 - displayName: 'Run Benchmarks' - inputs: - command: 'custom' - custom: 'run' - arguments: '--project $(PathToCommunityToolkitBenchmarkCsproj) --configuration Release' - - - task: PublishPipelineArtifact@1 - condition: eq(variables['Agent.OS'], 'Windows_NT') # Only run this step on Windows - displayName: 'Publish Benchmark Artifacts' - inputs: - targetPath: '$(Build.SourcesDirectory)/**/BenchmarkDotNet.Artifacts' - artifact: 'benchmark-results' - publishLocation: 'pipeline' - # pack - task: CmdLine@2 displayName: 'Build and Pack CommunityToolkit.Maui.Markup' @@ -213,3 +240,60 @@ jobs: inputs: artifactName: nuget pathToPublish: '$(Build.ArtifactStagingDirectory)' + + - job: run_benchmarks + displayName: Run Benchmarks + strategy: + matrix: + 'Windows': + image: 'windows-latest' + 'macOS': + image: 'macos-13' + pool: + vmImage: $(image) + steps: + - task: CmdLine@2 + displayName: 'Set Xcode v$(XcodeVersion)' + condition: eq(variables['Agent.OS'], 'Darwin') # Only run this step on macOS + inputs: + script: echo '##vso[task.setvariable variable=MD_APPLE_SDK_ROOT;]'/Applications/Xcode_$(XcodeVersion).app;sudo xcode-select --switch /Applications/Xcode_$(XcodeVersion).app/Contents/Developer + + - task: UseDotNet@2 + displayName: 'Install .NET SDK' + inputs: + packageType: 'sdk' + version: '$(NET_VERSION)' + includePreviewVersions: false + + - task: CmdLine@2 + displayName: 'Install .NET MAUI Workload' + inputs: + script : 'dotnet workload install maui' + + - pwsh: | + Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1' + .\workload-install.ps1 + displayName: Install Tizen Workload + + # Print Information on the .NET SDK Used By the CI Build Host + # These logs are useful information when debugging CI Builds + # Note: This step doesn't execute nor modify any code; it is strictly used for logging + debugging purposes + - task: CmdLine@2 + displayName: 'Display dotnet --info' + inputs: + script: dotnet --info + + - task: DotNetCoreCLI@2 + displayName: 'Run Benchmarks' + inputs: + command: 'custom' + custom: 'run' + arguments: '--project $(PathToCommunityToolkitBenchmarkCsproj) --configuration Release' + + - task: PublishPipelineArtifact@1 + condition: eq(variables['Agent.OS'], 'Windows_NT') # Only run this step on Windows + displayName: 'Publish Benchmark Artifacts' + inputs: + targetPath: '$(Build.SourcesDirectory)/**/BenchmarkDotNet.Artifacts' + artifact: 'benchmark-results' + publishLocation: 'pipeline' From dcab3da5e4549feb6aa1cb24bf511e16c8f8c9c5 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:26:13 -0700 Subject: [PATCH 11/25] Update azure-pipelines.yml --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 085c655f..415ec8c1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -282,7 +282,7 @@ jobs: displayName: 'Display dotnet --info' inputs: script: dotnet --info - + - task: DotNetCoreCLI@2 displayName: 'Run Benchmarks' inputs: @@ -294,6 +294,6 @@ jobs: condition: eq(variables['Agent.OS'], 'Windows_NT') # Only run this step on Windows displayName: 'Publish Benchmark Artifacts' inputs: - targetPath: '$(Build.SourcesDirectory)/**/BenchmarkDotNet.Artifacts' + targetPath: '$(Build.SourcesDirectory)/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts' artifact: 'benchmark-results' publishLocation: 'pipeline' From 7658f441b7730a7ed5cf4806fbc12a870a271d4f Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:41:52 -0700 Subject: [PATCH 12/25] Add `CommunityToolkit.Maui.Markup.Benchmarks.csproj` --- samples/CommunityToolkit.Maui.Markup.Sample.sln | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/samples/CommunityToolkit.Maui.Markup.Sample.sln b/samples/CommunityToolkit.Maui.Markup.Sample.sln index 0a387272..14dd228a 100644 --- a/samples/CommunityToolkit.Maui.Markup.Sample.sln +++ b/samples/CommunityToolkit.Maui.Markup.Sample.sln @@ -20,6 +20,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{A919 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Maui.Markup.SourceGenerators", "..\src\CommunityToolkit.Maui.Markup.SourceGenerators\CommunityToolkit.Maui.Markup.SourceGenerators.csproj", "{533792FE-99CD-4B5B-A8B2-51A8BE3852A5}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Maui.Markup.Benchmarks", "..\src\CommunityToolkit.Maui.Markup.Benchmarks\CommunityToolkit.Maui.Markup.Benchmarks.csproj", "{8C1B7D06-75D7-40AC-9FDB-344BF5FCCD5E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -44,6 +46,10 @@ Global {533792FE-99CD-4B5B-A8B2-51A8BE3852A5}.Debug|Any CPU.Build.0 = Debug|Any CPU {533792FE-99CD-4B5B-A8B2-51A8BE3852A5}.Release|Any CPU.ActiveCfg = Release|Any CPU {533792FE-99CD-4B5B-A8B2-51A8BE3852A5}.Release|Any CPU.Build.0 = Release|Any CPU + {8C1B7D06-75D7-40AC-9FDB-344BF5FCCD5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8C1B7D06-75D7-40AC-9FDB-344BF5FCCD5E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8C1B7D06-75D7-40AC-9FDB-344BF5FCCD5E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8C1B7D06-75D7-40AC-9FDB-344BF5FCCD5E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 8361906bbd6c6f5ad9e1ae5587da494833fd3483 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:44:21 -0700 Subject: [PATCH 13/25] Update azure-pipelines.yml --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 415ec8c1..6939338a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -294,6 +294,6 @@ jobs: condition: eq(variables['Agent.OS'], 'Windows_NT') # Only run this step on Windows displayName: 'Publish Benchmark Artifacts' inputs: - targetPath: '$(Build.SourcesDirectory)/src/CommunityToolkit.Maui.Markup.Benchmarks/BenchmarkDotNet.Artifacts' + targetPath: '$(Build.SourcesDirectory)\src\CommunityToolkit.Maui.Markup.Benchmarks\BenchmarkDotNet.Artifacts' artifact: 'benchmark-results' publishLocation: 'pipeline' From 324af0adf110604b1b17f9c8517debc8f00bd03d Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:57:11 -0700 Subject: [PATCH 14/25] Update azure-pipelines.yml --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6939338a..2c52112c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -294,6 +294,6 @@ jobs: condition: eq(variables['Agent.OS'], 'Windows_NT') # Only run this step on Windows displayName: 'Publish Benchmark Artifacts' inputs: - targetPath: '$(Build.SourcesDirectory)\src\CommunityToolkit.Maui.Markup.Benchmarks\BenchmarkDotNet.Artifacts' + targetPath: '\src\CommunityToolkit.Maui.Markup.Benchmarks\BenchmarkDotNet.Artifacts\' artifact: 'benchmark-results' publishLocation: 'pipeline' From 3c557b065a06d2dd557325aaa12f487b69484e90 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Fri, 21 Jun 2024 10:23:29 -0700 Subject: [PATCH 15/25] Update Benchmark CI --- azure-pipelines.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2c52112c..0877785e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -283,17 +283,15 @@ jobs: inputs: script: dotnet --info - - task: DotNetCoreCLI@2 + - task: CmdLine@2 displayName: 'Run Benchmarks' inputs: - command: 'custom' - custom: 'run' - arguments: '--project $(PathToCommunityToolkitBenchmarkCsproj) --configuration Release' + script : 'dotnet run $(PathToCommunityToolkitBenchmarkCsproj) -c Release' - task: PublishPipelineArtifact@1 condition: eq(variables['Agent.OS'], 'Windows_NT') # Only run this step on Windows displayName: 'Publish Benchmark Artifacts' inputs: - targetPath: '\src\CommunityToolkit.Maui.Markup.Benchmarks\BenchmarkDotNet.Artifacts\' + targetPath: 'src\CommunityToolkit.Maui.Markup.Benchmarks\BenchmarkDotNet.Artifacts\' artifact: 'benchmark-results' publishLocation: 'pipeline' From 0e181b38dc460283f419828cf91dd86f8e9d36d5 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Fri, 21 Jun 2024 10:30:46 -0700 Subject: [PATCH 16/25] Use `--project` --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0877785e..1e2d1e0e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,7 +12,7 @@ variables: PathToCommunityToolkitUnitTestCsproj: 'src/CommunityToolkit.Maui.Markup.UnitTests/CommunityToolkit.Maui.Markup.UnitTests.csproj' PathToCommunityToolkitBenchmarkCsproj: 'src/CommunityToolkit.Maui.Markup.Benchmarks/CommunityToolkit.Maui.Markup.Benchmarks.csproj' PathToCommunityToolkitSourceGeneratorsCsproj: 'src/CommunityToolkit.Maui.Markup.SourceGenerators/CommunityToolkit.Maui.Markup.SourceGenerators.csproj' - XcodeVersion: '15.2.0' + XcodeVersion: '15.3.0' ShouldCheckDependencies: true trigger: @@ -286,7 +286,7 @@ jobs: - task: CmdLine@2 displayName: 'Run Benchmarks' inputs: - script : 'dotnet run $(PathToCommunityToolkitBenchmarkCsproj) -c Release' + script : 'dotnet run --project $(PathToCommunityToolkitBenchmarkCsproj) -c Release' - task: PublishPipelineArtifact@1 condition: eq(variables['Agent.OS'], 'Windows_NT') # Only run this step on Windows From 32b2c994db72c8157156b25c4bf09ce3e1fcaaa8 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Fri, 21 Jun 2024 10:48:27 -0700 Subject: [PATCH 17/25] Update azure-pipelines.yml --- azure-pipelines.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1e2d1e0e..f99cc542 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -50,7 +50,7 @@ jobs: 'Windows': image: 'windows-latest' 'macOS': - image: 'macos-13' + image: 'macos-14' pool: vmImage: $(image) steps: @@ -97,7 +97,7 @@ jobs: 'Windows': image: 'windows-latest' 'macOS': - image: 'macos-13' + image: 'macos-14' pool: vmImage: $(image) steps: @@ -248,7 +248,7 @@ jobs: 'Windows': image: 'windows-latest' 'macOS': - image: 'macos-13' + image: 'macos14' pool: vmImage: $(image) steps: @@ -292,6 +292,5 @@ jobs: condition: eq(variables['Agent.OS'], 'Windows_NT') # Only run this step on Windows displayName: 'Publish Benchmark Artifacts' inputs: - targetPath: 'src\CommunityToolkit.Maui.Markup.Benchmarks\BenchmarkDotNet.Artifacts\' artifact: 'benchmark-results' publishLocation: 'pipeline' From d71f3f65836fb3a5ba1764c51495c9b1e262875c Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Fri, 21 Jun 2024 10:57:06 -0700 Subject: [PATCH 18/25] Publish Benchmark Results to `$(Build.ArtifactStagingDirectory)` --- azure-pipelines.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f99cc542..0e1730b1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -248,7 +248,7 @@ jobs: 'Windows': image: 'windows-latest' 'macOS': - image: 'macos14' + image: 'macos-14' pool: vmImage: $(image) steps: @@ -286,11 +286,12 @@ jobs: - task: CmdLine@2 displayName: 'Run Benchmarks' inputs: - script : 'dotnet run --project $(PathToCommunityToolkitBenchmarkCsproj) -c Release' + script : 'dotnet run --project $(PathToCommunityToolkitBenchmarkCsproj) -c Release -- -a $(Build.ArtifactStagingDirectory)' - - task: PublishPipelineArtifact@1 + # publish the Benchmark Results + - task: PublishBuildArtifacts@1 condition: eq(variables['Agent.OS'], 'Windows_NT') # Only run this step on Windows displayName: 'Publish Benchmark Artifacts' inputs: - artifact: 'benchmark-results' - publishLocation: 'pipeline' + artifactName: benchmarks + pathToPublish: '$(Build.ArtifactStagingDirectory)' From ce5623a9f813204f2ce188ebe00a1eb5a891282d Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:10:12 -0700 Subject: [PATCH 19/25] Disable Code Signing --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0e1730b1..d4877bee 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -88,7 +88,7 @@ jobs: - task: CmdLine@2 displayName: 'Build CommunityToolkit.Maui.Markup.Sample' inputs: - script: 'dotnet build -c Release $(PathToCommunityToolkitSampleCsproj)' + script: 'dotnet build -c Release $(PathToCommunityToolkitSampleCsproj) /p:EnableCodeSigning=false' - job: build_library displayName: Build Library From 6873d70d86e460ce047978d901303ccec02d45bc Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:15:58 -0700 Subject: [PATCH 20/25] Update azure-pipelines.yml --- azure-pipelines.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d4877bee..c79c3bd0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -50,7 +50,7 @@ jobs: 'Windows': image: 'windows-latest' 'macOS': - image: 'macos-14' + image: 'macos-latest-large' pool: vmImage: $(image) steps: @@ -88,7 +88,7 @@ jobs: - task: CmdLine@2 displayName: 'Build CommunityToolkit.Maui.Markup.Sample' inputs: - script: 'dotnet build -c Release $(PathToCommunityToolkitSampleCsproj) /p:EnableCodeSigning=false' + script: 'dotnet build -c Release $(PathToCommunityToolkitSampleCsproj)' - job: build_library displayName: Build Library @@ -97,7 +97,7 @@ jobs: 'Windows': image: 'windows-latest' 'macOS': - image: 'macos-14' + image: 'macos-latest-large' pool: vmImage: $(image) steps: @@ -248,7 +248,7 @@ jobs: 'Windows': image: 'windows-latest' 'macOS': - image: 'macos-14' + image: 'macos-latest-large' pool: vmImage: $(image) steps: From 8fd17cbb61f925b149b327e69fb8798778fa26fe Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:17:25 -0700 Subject: [PATCH 21/25] Update azure-pipelines.yml --- azure-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c79c3bd0..d158a48c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -50,7 +50,7 @@ jobs: 'Windows': image: 'windows-latest' 'macOS': - image: 'macos-latest-large' + image: 'macos-14-large' pool: vmImage: $(image) steps: @@ -97,7 +97,7 @@ jobs: 'Windows': image: 'windows-latest' 'macOS': - image: 'macos-latest-large' + image: 'macos-14-large' pool: vmImage: $(image) steps: @@ -248,7 +248,7 @@ jobs: 'Windows': image: 'windows-latest' 'macOS': - image: 'macos-latest-large' + image: 'macos-14-large' pool: vmImage: $(image) steps: From cf4561998f72ad4f2498dba0e460d3e6dc97996e Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:19:24 -0700 Subject: [PATCH 22/25] Update azure-pipelines.yml --- azure-pipelines.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d158a48c..06559bd6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -50,15 +50,13 @@ jobs: 'Windows': image: 'windows-latest' 'macOS': - image: 'macos-14-large' + image: 'macos-14' pool: vmImage: $(image) steps: - - task: CmdLine@2 + - script: | + sudo xcode-select -s /Applications/Xcode_.app displayName: 'Set Xcode v$(XcodeVersion)' - condition: eq(variables['Agent.OS'], 'Darwin') # Only run this step on macOS - inputs: - script: echo '##vso[task.setvariable variable=MD_APPLE_SDK_ROOT;]'/Applications/Xcode_$(XcodeVersion).app;sudo xcode-select --switch /Applications/Xcode_$(XcodeVersion).app/Contents/Developer - task: UseDotNet@2 displayName: 'Install .NET SDK' @@ -97,7 +95,7 @@ jobs: 'Windows': image: 'windows-latest' 'macOS': - image: 'macos-14-large' + image: 'macos-14' pool: vmImage: $(image) steps: @@ -248,7 +246,7 @@ jobs: 'Windows': image: 'windows-latest' 'macOS': - image: 'macos-14-large' + image: 'macos-14' pool: vmImage: $(image) steps: From 73390e9dbd68a248affa6a50f11c8b6ac42b8e7a Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:20:44 -0700 Subject: [PATCH 23/25] Update azure-pipelines.yml --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 06559bd6..2f5173e3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -55,7 +55,7 @@ jobs: vmImage: $(image) steps: - script: | - sudo xcode-select -s /Applications/Xcode_.app + sudo xcode-select -s /Applications/Xcode_$(XcodeVersion).app displayName: 'Set Xcode v$(XcodeVersion)' - task: UseDotNet@2 From 8f341858a297928bde6d71de627ebc84589e840c Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:27:54 -0700 Subject: [PATCH 24/25] Update azure-pipelines.yml --- azure-pipelines.yml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2f5173e3..7d2dde85 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,7 +12,7 @@ variables: PathToCommunityToolkitUnitTestCsproj: 'src/CommunityToolkit.Maui.Markup.UnitTests/CommunityToolkit.Maui.Markup.UnitTests.csproj' PathToCommunityToolkitBenchmarkCsproj: 'src/CommunityToolkit.Maui.Markup.Benchmarks/CommunityToolkit.Maui.Markup.Benchmarks.csproj' PathToCommunityToolkitSourceGeneratorsCsproj: 'src/CommunityToolkit.Maui.Markup.SourceGenerators/CommunityToolkit.Maui.Markup.SourceGenerators.csproj' - XcodeVersion: '15.3.0' + XcodeVersion: '15.2.0' ShouldCheckDependencies: true trigger: @@ -55,8 +55,10 @@ jobs: vmImage: $(image) steps: - script: | - sudo xcode-select -s /Applications/Xcode_$(XcodeVersion).app + sudo xcode-select -s /Applications/Xcode_$(XcodeVersion).app + sudo xcode-select -p displayName: 'Set Xcode v$(XcodeVersion)' + condition: eq(variables['Agent.OS'], 'Darwin') # Only run this step on macOS - task: UseDotNet@2 displayName: 'Install .NET SDK' @@ -119,11 +121,11 @@ jobs: displayName: Set NuGet Version to PR Version condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'), eq(variables['build.reason'], 'PullRequest')) - - task: CmdLine@2 + - script: | + sudo xcode-select -s /Applications/Xcode_$(XcodeVersion).app + sudo xcode-select -p displayName: 'Set Xcode v$(XcodeVersion)' condition: eq(variables['Agent.OS'], 'Darwin') # Only run this step on macOS - inputs: - script: echo '##vso[task.setvariable variable=MD_APPLE_SDK_ROOT;]'/Applications/Xcode_$(XcodeVersion).app;sudo xcode-select --switch /Applications/Xcode_$(XcodeVersion).app/Contents/Developer - task: UseDotNet@2 displayName: 'Install .NET SDK' @@ -250,11 +252,11 @@ jobs: pool: vmImage: $(image) steps: - - task: CmdLine@2 + - script: | + sudo xcode-select -s /Applications/Xcode_$(XcodeVersion).app + sudo xcode-select -p displayName: 'Set Xcode v$(XcodeVersion)' condition: eq(variables['Agent.OS'], 'Darwin') # Only run this step on macOS - inputs: - script: echo '##vso[task.setvariable variable=MD_APPLE_SDK_ROOT;]'/Applications/Xcode_$(XcodeVersion).app;sudo xcode-select --switch /Applications/Xcode_$(XcodeVersion).app/Contents/Developer - task: UseDotNet@2 displayName: 'Install .NET SDK' From 4102b4bf5f2d5bbb14021c6d25efcdd93cb4262b Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:37:04 -0700 Subject: [PATCH 25/25] Update azure-pipelines.yml --- azure-pipelines.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7d2dde85..7d448f1b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,7 +12,8 @@ variables: PathToCommunityToolkitUnitTestCsproj: 'src/CommunityToolkit.Maui.Markup.UnitTests/CommunityToolkit.Maui.Markup.UnitTests.csproj' PathToCommunityToolkitBenchmarkCsproj: 'src/CommunityToolkit.Maui.Markup.Benchmarks/CommunityToolkit.Maui.Markup.Benchmarks.csproj' PathToCommunityToolkitSourceGeneratorsCsproj: 'src/CommunityToolkit.Maui.Markup.SourceGenerators/CommunityToolkit.Maui.Markup.SourceGenerators.csproj' - XcodeVersion: '15.2.0' + CommunityToolkitSampleApp_Xcode_Version: '15.2.0' + CommunityToolkitLibrary_Xcode_Version: '15.3.0' ShouldCheckDependencies: true trigger: @@ -55,9 +56,9 @@ jobs: vmImage: $(image) steps: - script: | - sudo xcode-select -s /Applications/Xcode_$(XcodeVersion).app + sudo xcode-select -s /Applications/Xcode_$(CommunityToolkitSampleApp_Xcode_Version).app sudo xcode-select -p - displayName: 'Set Xcode v$(XcodeVersion)' + displayName: 'Set Xcode v$(CommunityToolkitSampleApp_Xcode_Version)' condition: eq(variables['Agent.OS'], 'Darwin') # Only run this step on macOS - task: UseDotNet@2 @@ -122,9 +123,9 @@ jobs: condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'), eq(variables['build.reason'], 'PullRequest')) - script: | - sudo xcode-select -s /Applications/Xcode_$(XcodeVersion).app + sudo xcode-select -s /Applications/Xcode_$(CommunityToolkitLibrary_Xcode_Version).app sudo xcode-select -p - displayName: 'Set Xcode v$(XcodeVersion)' + displayName: 'Set Xcode v$(CommunityToolkitLibrary_Xcode_Version)' condition: eq(variables['Agent.OS'], 'Darwin') # Only run this step on macOS - task: UseDotNet@2 @@ -253,9 +254,9 @@ jobs: vmImage: $(image) steps: - script: | - sudo xcode-select -s /Applications/Xcode_$(XcodeVersion).app + sudo xcode-select -s /Applications/Xcode_$(CommunityToolkitLibrary_Xcode_Version).app sudo xcode-select -p - displayName: 'Set Xcode v$(XcodeVersion)' + displayName: 'Set Xcode v$(CommunityToolkitLibrary_Xcode_Version)' condition: eq(variables['Agent.OS'], 'Darwin') # Only run this step on macOS - task: UseDotNet@2