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
23 changes: 8 additions & 15 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ on:

env:
LATEST_NET_VERSION: '10.0.x'
PathToCommunityToolkitAnalyzersBenchmarkCsproj: 'src/CommunityToolkit.Maui.Analyzers.Benchmarks/CommunityToolkit.Maui.Analyzers.Benchmarks.csproj'
PathToCommunityToolkitAnalyzersBenchmarksCsproj: 'src/CommunityToolkit.Maui.Analyzers.Benchmarks/CommunityToolkit.Maui.Analyzers.Benchmarks.csproj'
PathToCommunityToolkitSourceGeneratorsBenchmarksCsproj: 'src/CommunityToolkit.Maui.SourceGenerators.Benchmarks/CommunityToolkit.Maui.SourceGenerators.Benchmarks.csproj'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand All @@ -23,21 +24,11 @@ concurrency:
jobs:
run_benchmarks:
name: Run Benchmarks
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ windows-latest, macos-26 ]

runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@main

- uses: maxim-lobanov/setup-xcode@v1
if: runner.os == 'macOS'
with:
xcode-version: latest-stable

- name: Install Latest Version of .NET, v${{ env.LATEST_NET_VERSION }}
uses: actions/setup-dotnet@v5
with:
Expand All @@ -58,11 +49,13 @@ jobs:
- name: Display dotnet info
run: dotnet --info

- name: Run Benchmarks
run: dotnet run --project ${{ env.PathToCommunityToolkitAnalyzersBenchmarkCsproj }} -c Release -- -a ${{ runner.temp }}
- name: Run Analyzer Benchmarks
run: dotnet run --project ${{ env.PathToCommunityToolkitAnalyzersBenchmarksCsproj }} -c Release -- -a "${{ runner.temp }}"

- name: Run Source Generator Benchmarks
run: dotnet run --project ${{ env.PathToCommunityToolkitSourceGeneratorsBenchmarksCsproj }} -c Release -- -a "${{ runner.temp }}"

- name: Publish Benchmarks
if: runner.os == 'Windows'
uses: actions/upload-artifact@v5
with:
name: Benchmarks
Expand Down
1 change: 1 addition & 0 deletions samples/CommunityToolkit.Maui.Sample.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
</Folder>
<Folder Name="/Benchmarks/">
<Project Path="../src/CommunityToolkit.Maui.Analyzers.Benchmarks/CommunityToolkit.Maui.Analyzers.Benchmarks.csproj" />
<Project Path="../src/CommunityToolkit.Maui.SourceGenerators.Benchmarks/CommunityToolkit.Maui.SourceGenerators.Benchmarks.csproj" Id="cc195bb1-9cac-410e-81fe-23665f99f294" />
</Folder>
<Folder Name="/Samples/">
<Project Path="CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using BenchmarkDotNet.Attributes;
using CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests.BindablePropertyAttributeSourceGeneratorTests;

namespace CommunityToolkit.Maui.SourceGenerators.Benchmarks;

[MemoryDiagnoser]
public class BindablePropertyAttributeSourceGeneratorBenchmarks
{
static readonly CommonUsageTests commonUsageTests = new();
static readonly EdgeCaseTests edgeCaseTests = new();
static readonly IntegrationTests integrationTests = new();

[Benchmark]
public Task GenerateBindableProperty_SimpleExample_GeneratesCorrectCode()
=> commonUsageTests.GenerateBindableProperty_SimpleExample_GeneratesCorrectCode();

[Benchmark]
public Task GenerateBindableProperty_MultipleProperties_GeneratesCorrectCode()
=> commonUsageTests.GenerateBindableProperty_MultipleProperties_GeneratesCorrectCode();

[Benchmark]
public Task GenerateBindableProperty_WithAllParameters_GeneratesCorrectCode()
=> commonUsageTests.GenerateBindableProperty_WithAllParameters_GeneratesCorrectCode();

[Benchmark]
public Task GenerateBindableProperty_InternalClass_GeneratesCorrectCode()
=> commonUsageTests.GenerateBindableProperty_InternalClass_GeneratesCorrectCode();

[Benchmark]
public Task GenerateBindableProperty_ComplexInheritanceScenario_GeneratesCorrectCode()
=> integrationTests.GenerateBindableProperty_ComplexInheritanceScenario_GeneratesCorrectCode();

[Benchmark]
public Task GenerateBindableProperty_NestedClass_GeneratesCorrectCode()
=> integrationTests.GenerateBindableProperty_NestedClass_GeneratesCorrectCode();

[Benchmark]
public Task GenerateBindableProperty_WithComplexDefaultValues_GeneratesCorrectCode()
=> edgeCaseTests.GenerateBindableProperty_WithComplexDefaultValues_GeneratesCorrectCode();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(NetVersion)</TargetFramework>
<OutputType>Exe</OutputType>
<StartupObject>CommunityToolkit.Maui.SourceGenerators.Benchmarks.Program</StartupObject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.15.7" />

</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests\CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests.csproj" />
<ProjectReference Include="..\CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.csproj" />
</ItemGroup>
</Project>
13 changes: 13 additions & 0 deletions src/CommunityToolkit.Maui.SourceGenerators.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Running;

namespace CommunityToolkit.Maui.SourceGenerators.Benchmarks;

class Program
{
public static void Main(string[] args)
{
var config = DefaultConfig.Instance;
BenchmarkRunner.Run<BindablePropertyAttributeSourceGeneratorBenchmarks>(config, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests.BindablePropertyAttributeSourceGeneratorTests;

public class BindablePropertyAttributeSourceGeneratorTests : BaseBindablePropertyAttributeSourceGeneratorTest
public class CommonUsageTests : BaseBindablePropertyAttributeSourceGeneratorTest
{
[Fact]
public async Task GenerateBindableProperty_SimpleExample_GeneratesCorrectCode()
Expand Down
Loading
Loading