Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional tests and benchmarks for async. #1538

Merged
merged 8 commits into from
Mar 15, 2024
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
19 changes: 16 additions & 3 deletions build/AzurePipelineTemplates/CsWinRT-Benchmarks-Steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,25 @@ steps:
script: |
Write-Host ##vso[task.setvariable variable=PATH;]${env:LocalAppData}\Microsoft\dotnet;${env:PATH};

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;

dotnet new globaljson --sdk-version "$($env:NET6_SDK_VERSION)"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;

&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version "$($env:NET6_SDK_VERSION)" -Architecture "x64" -AzureFeed "$($env:NET5_SDK_FEED)"

# Install .NET 8 SDK
- task: PowerShell@2
displayName: Install .NET 8 SDK
inputs:
targetType: inline
failOnStderr: true
script: |
Write-Host ##vso[task.setvariable variable=PATH;]${env:LocalAppData}\Microsoft\dotnet;${env:PATH};

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;

dotnet new globaljson --sdk-version "$($env:NET8_SDK_VERSION)"

&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version "$($env:NET8_SDK_VERSION)" -Architecture "x64" -AzureFeed "$($env:NET5_SDK_FEED)"

# Verify .NET SDK
- task: CmdLine@2
displayName: Verify .NET SDK
Expand Down
17 changes: 15 additions & 2 deletions build/AzurePipelineTemplates/CsWinRT-Build-Steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,23 @@ steps:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;

dotnet new globaljson --sdk-version "$($env:NET6_SDK_VERSION)"

&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version "$($env:NET6_SDK_VERSION)" -Architecture "x64" -AzureFeed "$($env:NET5_SDK_FEED)"

# Install .NET 8 SDK
- task: PowerShell@2
displayName: Install .NET 8 SDK
inputs:
targetType: inline
failOnStderr: true
script: |
Write-Host ##vso[task.setvariable variable=PATH;]${env:LocalAppData}\Microsoft\dotnet;${env:PATH};

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;

dotnet new globaljson --sdk-version "$($env:NET8_SDK_VERSION)"

&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version "$($env:NET8_SDK_VERSION)" -Architecture "x64" -AzureFeed "$($env:NET5_SDK_FEED)"

# Verify .NET SDK
- task: CmdLine@2
displayName: Verify .NET SDK
Expand Down
3 changes: 2 additions & 1 deletion build/AzurePipelineTemplates/CsWinRT-Variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ variables:
PatchVersion: 7
WinRT.Runtime.AssemblyVersion: '2.0.0.0'
Net5.SDK.Feed: 'https://dotnetcli.blob.core.windows.net/dotnet'
Net6.SDK.Version: '6.0.415'
Net6.SDK.Version: '6.0.420'
Net8.SDK.Version: '8.0.103'
NoSamples: 'false'

# This 'coalesce' pattern allows the yml to define a default value for a variable but allows the value to be overridden at queue time.
Expand Down
43 changes: 43 additions & 0 deletions src/Benchmarks/AsyncPerf.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.Threading.Tasks;
using BenchmarkComponent;
using BenchmarkDotNet.Attributes;

namespace Benchmarks
{
[MemoryDiagnoser]
public class AsyncPerf
{
ClassWithAsync instance;

[GlobalSetup]
public void Setup()
{
instance = new ClassWithAsync();
}

[Benchmark]
public async Task Complete()
{
await instance.Complete();
}

[Benchmark]
public async Task YieldComplete()
{
await instance.YieldComplete();
}

[Benchmark]
public async Task<int> Return()
{
return await instance.Return(5);
}

[Benchmark]
public async Task<int> YieldReturn()
{
return await instance.YieldReturn(5);
}
}
}
4 changes: 0 additions & 4 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
<None Include="$(GeneratedFilesRootDir)**/*.cs" />
<Compile Condition="'$(GeneratedFilesDir)' != '$(GeneratedFilesRootDir)'" Include="$(GeneratedFilesDir)*.cs" />
</ItemGroup>

<ItemGroup Condition="'$(MSBuildProjectExtension)' == '.csproj'">
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="4.8.0-2.final" />
</ItemGroup>

<ItemGroup>
<FrameworkReference Remove="Microsoft.Windows.SDK.NET.Ref" />
Expand Down
4 changes: 2 additions & 2 deletions src/build.cmd
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@echo off
if /i "%cswinrt_echo%" == "on" @echo on

set CsWinRTBuildNetSDKVersion=6.0.415
set CsWinRTBuildNetSDKVersion=6.0.420
set CsWinRTBuildNet7SDKVersion=7.0.402
set CsWinRTBuildNet8SDKVersion=8.0.100
set CsWinRTBuildNet8SDKVersion=8.0.103
set this_dir=%~dp0

:dotnet
Expand Down
4 changes: 2 additions & 2 deletions src/get_testwinrt.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ git checkout -f master
if ErrorLevel 1 popd & exit /b !ErrorLevel!
git fetch -f
if ErrorLevel 1 popd & exit /b !ErrorLevel!
git reset -q --hard 1bdde092ca6031f86b659212db1fa00bb1d5c9af
git reset -q --hard 00fdd7b98daa0156f4214d0a8eb3afffc89efe48
if ErrorLevel 1 popd & exit /b !ErrorLevel!
echo Restoring Nuget
%this_dir%.nuget\nuget.exe restore
popd
exit /b 0
exit /b 0