From 15ed71a1c70154c1d195577e8808fb3335b3b1a2 Mon Sep 17 00:00:00 2001 From: Manodasan Wignarajah Date: Fri, 26 Jun 2020 08:06:27 -0700 Subject: [PATCH 01/11] Adding BenchmarkDotNet for benchmarking and adding bencmarking for cswinrt projection on .netcore 2.0, 3.1, 5 and benchmarking for winmd projection on net core 3.1. --- Benchmarks/Benchmarks.csproj | 53 +++++++++++++++++++ Benchmarks/Benchmarks.manifest | 12 +++++ Benchmarks/Program.cs | 96 ++++++++++++++++++++++++++++++++++ Benchmarks/QueryInterface.cs | 78 +++++++++++++++++++++++++++ benchmark.cmd | 2 + benchmark_winmd.cmd | 4 ++ 6 files changed, 245 insertions(+) create mode 100644 Benchmarks/Benchmarks.csproj create mode 100644 Benchmarks/Benchmarks.manifest create mode 100644 Benchmarks/Program.cs create mode 100644 Benchmarks/QueryInterface.cs create mode 100644 benchmark.cmd create mode 100644 benchmark_winmd.cmd diff --git a/Benchmarks/Benchmarks.csproj b/Benchmarks/Benchmarks.csproj new file mode 100644 index 000000000..4d2245383 --- /dev/null +++ b/Benchmarks/Benchmarks.csproj @@ -0,0 +1,53 @@ + + + + Exe + x64;x86 + netcoreapp2.0;net5.0;netcoreapp3.1 + false + false + + true + Benchmarks.manifest + + + + + + + + + + + + + + + + BenchmarkComponent.dll + PreserveNewest + True + + + + $(MSBuildThisFileDirectory)..\_build\$(Platform)\$(Configuration)\BenchmarkComponent\bin\BenchmarkComponent\BenchmarkComponent.winmd + true + + + + + Benchmarks.manifest + PreserveNewest + True + + + + + + + + + + + + diff --git a/Benchmarks/Benchmarks.manifest b/Benchmarks/Benchmarks.manifest new file mode 100644 index 000000000..74774097c --- /dev/null +++ b/Benchmarks/Benchmarks.manifest @@ -0,0 +1,12 @@ + + + + + + + + + diff --git a/Benchmarks/Program.cs b/Benchmarks/Program.cs new file mode 100644 index 000000000..03a29cf41 --- /dev/null +++ b/Benchmarks/Program.cs @@ -0,0 +1,96 @@ +using BenchmarkDotNet.Running; +using System; +using BenchmarkDotNet.Configs; +using BenchmarkDotNet.Jobs; +using BenchmarkDotNet.Toolchains.CsProj; +using BenchmarkDotNet.Toolchains.DotNetCli; +using BenchmarkDotNet.Toolchains; +using BenchmarkDotNet.Loggers; +using BenchmarkDotNet.Characteristics; +using System.IO; + +namespace Benchmarks +{ + public class Program + { + static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, new CustomConfig().Config); + + private class CustomConfig : Attribute, IConfigSource + { + public IConfig Config { get; } = DefaultConfig.Instance; + + public CustomConfig() + { + // Test CsWinRT projection + var job = Job.Default + .WithPlatform(BenchmarkDotNet.Environments.Platform.X64) + .WithArguments( + new Argument[] { + new MsBuildArgument("/p:platform=x64"), + new MsBuildArgument("/p:MsAppxPackageTargets=%temp%\\EmptyMsAppxPackage.Targets") + } + ).AsDefault(); + + // Test WinMD support +#if NETCOREAPP3_1 + // BenchmarkDotNet will rebuild the project with a project reference when this exe is ran and + // in the same folder as it we have the application manifest binplaced which we want to embed in the new exe. + string manifestFile = Path.Combine( + Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), + "Benchmarks.manifest"); + + var winmdJob = Job.Default + .WithPlatform(BenchmarkDotNet.Environments.Platform.X64) + .WithToolchain(new NetCore3ToolChainWithNativeExecution()) + .WithArguments( + new Argument[] { + new MsBuildArgument("/p:platform=x64"), + new MsBuildArgument("/p:ApplicationManifest=" + manifestFile), + new MsBuildArgument("/p:BenchmarkWinmdSupport=true") + } + ) + .WithId("WinMD NetCoreApp31"); + + // Optimizer needs to be diabled as it errors on WinMDs + Config = Config.WithOption(ConfigOptions.DisableOptimizationsValidator, true) + .AddJob(winmdJob); +#else + Config = Config.AddJob(job); +#endif + } + } + + // Custom tool chain for building the benchmark with WinMDs as we need to execute the + // exe version of the benchmark rather than the dll version which runs under dotnet cli. + // This is becuase we need to be able to embed a side by side manifest for reg free winrt + // and to enable COM to find the WinMDs. + private class NetCore3ToolChainWithNativeExecution : Toolchain + { + public NetCore3ToolChainWithNativeExecution() + : base("netcoreapp3.1-native", + new CsProjGeneratorWithNativeExe(NetCoreAppSettings.NetCoreApp31), + CsProjCoreToolchain.NetCoreApp31.Builder, + new Executor()) + { + } + + public override bool IsSupported(BenchmarkCase benchmarkCase, ILogger logger, IResolver resolver) + { + return CsProjCoreToolchain.NetCoreApp31.IsSupported(benchmarkCase, logger, resolver); + } + } + + private class CsProjGeneratorWithNativeExe : CsProjGenerator + { + public CsProjGeneratorWithNativeExe(NetCoreAppSettings settings) + :base(settings.TargetFrameworkMoniker, settings.CustomDotNetCliPath, settings.PackagesPath, settings.RuntimeFrameworkVersion) + { + } + + protected override string GetExecutableExtension() + { + return ".exe"; + } + } + } +} diff --git a/Benchmarks/QueryInterface.cs b/Benchmarks/QueryInterface.cs new file mode 100644 index 000000000..9f7441dc3 --- /dev/null +++ b/Benchmarks/QueryInterface.cs @@ -0,0 +1,78 @@ +using BenchmarkComponent; +using BenchmarkDotNet.Attributes; +using Windows.ApplicationModel.Chat; + +namespace Benchmarks +{ + public class QueryInterfacePerf + { + ClassWithMultipleInterfaces instance; + ChatMessage message; + + [GlobalSetup] + public void Setup() + { + instance = new ClassWithMultipleInterfaces(); + message = new ChatMessage(); + } + + [Benchmark] + public int QueryDefaultInterface() + { + return instance.Property1; + } + + [Benchmark] + public int QueryNonDefaultInterface() + { + return instance.IntProperty1; + } + + [Benchmark] + public bool QueryNonDefaultInterface2() + { + return instance.BoolProperty1; + } + + [Benchmark] + public void QueryDefaultInterfaceSetProperty() + { + instance.Property1 = 4; + } + + [Benchmark] + public void QueryNonDefaultInterfaceSetProperty() + { + instance.IntProperty1 = 4; + } + + [Benchmark] + public bool QuerySDKDefaultInterface() + { + return message.IsForwardingDisabled; + } + + [Benchmark] + public bool QuerySDKNonDefaultInterface() + { + return message.IsSeen; + } + + // The following 2 benchmarks try to benchmark the time taken for the first call + // rather than the mean time over several calls. It has the overhead of the object + // construction, but it can be used to track regressions to performance. + [Benchmark] + public int ConstructAndQueryDefaultInterfaceFirstCall() + { + ClassWithMultipleInterfaces instance2 = new ClassWithMultipleInterfaces(); + return instance2.Property1; + } + + [Benchmark] + public int ConstructAndQueryNonDefaultInterfaceFirstCall() + { + ClassWithMultipleInterfaces instance2 = new ClassWithMultipleInterfaces(); + return instance2.IntProperty1; + } + } +} \ No newline at end of file diff --git a/benchmark.cmd b/benchmark.cmd new file mode 100644 index 000000000..7b2f42e7a --- /dev/null +++ b/benchmark.cmd @@ -0,0 +1,2 @@ +msbuild Benchmarks\Benchmarks.csproj -t:restore -t:build /p:platform=x64 /p:configuration=release +dotnet S:\CsWinRT\Benchmarks\bin\x64\Release\netcoreapp2.0\Benchmarks.dll -filter * --runtimes netcoreapp2.0 netcoreapp3.1 netcoreapp5.0 \ No newline at end of file diff --git a/benchmark_winmd.cmd b/benchmark_winmd.cmd new file mode 100644 index 000000000..e2d5c03aa --- /dev/null +++ b/benchmark_winmd.cmd @@ -0,0 +1,4 @@ +msbuild Benchmarks\Benchmarks.csproj -t:restore -t:clean;rebuild /p:BenchmarkWinmdSupport=true /p:platform=x64 /p:configuration=release /p:TargetFramework=netcoreapp3.1 +S:\CsWinRT\Benchmarks\bin\x64\Release\netcoreapp3.1\Benchmarks.exe -filter * +rem Clean project to prevent mismatch scenarios with the typical benchmark.cmd scenario. +msbuild Benchmarks\Benchmarks.csproj -t:restore -t:clean /p:BenchmarkWinmdSupport=true /p:platform=x64 /p:configuration=release /p:TargetFramework=netcoreapp3.1 >nul \ No newline at end of file From 404483965f7a4fd63b591ca74d26cbc1c0e9d063 Mon Sep 17 00:00:00 2001 From: Manodasan Wignarajah Date: Mon, 29 Jun 2020 13:13:07 -0700 Subject: [PATCH 02/11] Adding managed memory tracking. --- Benchmarks/QueryInterface.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Benchmarks/QueryInterface.cs b/Benchmarks/QueryInterface.cs index 9f7441dc3..eb6305f13 100644 --- a/Benchmarks/QueryInterface.cs +++ b/Benchmarks/QueryInterface.cs @@ -4,6 +4,7 @@ namespace Benchmarks { + [MemoryDiagnoser] public class QueryInterfacePerf { ClassWithMultipleInterfaces instance; From 193c04ffd72c477099c78cce319297c26c9565dd Mon Sep 17 00:00:00 2001 From: Manodasan Wignarajah Date: Tue, 30 Jun 2020 11:25:40 -0700 Subject: [PATCH 03/11] Adopting to changes to benchmarkcomponent --- Benchmarks/Benchmarks.csproj | 2 +- Benchmarks/QueryInterface.cs | 14 +++--- Projections/Benchmark/Benchmark.csproj | 68 ++++++++++++++++++++++++++ cswinrt.sln | 49 +++++++++++++++++++ 4 files changed, 125 insertions(+), 8 deletions(-) create mode 100644 Projections/Benchmark/Benchmark.csproj diff --git a/Benchmarks/Benchmarks.csproj b/Benchmarks/Benchmarks.csproj index 4d2245383..bd31585a1 100644 --- a/Benchmarks/Benchmarks.csproj +++ b/Benchmarks/Benchmarks.csproj @@ -20,7 +20,7 @@ - + diff --git a/Benchmarks/QueryInterface.cs b/Benchmarks/QueryInterface.cs index eb6305f13..567ef3aa9 100644 --- a/Benchmarks/QueryInterface.cs +++ b/Benchmarks/QueryInterface.cs @@ -20,31 +20,31 @@ public void Setup() [Benchmark] public int QueryDefaultInterface() { - return instance.Property1; + return instance.DefaultIntProperty; } [Benchmark] public int QueryNonDefaultInterface() { - return instance.IntProperty1; + return instance.IntProperty; } [Benchmark] public bool QueryNonDefaultInterface2() { - return instance.BoolProperty1; + return instance.BoolProperty; } [Benchmark] public void QueryDefaultInterfaceSetProperty() { - instance.Property1 = 4; + instance.DefaultIntProperty = 4; } [Benchmark] public void QueryNonDefaultInterfaceSetProperty() { - instance.IntProperty1 = 4; + instance.IntProperty = 4; } [Benchmark] @@ -66,14 +66,14 @@ public bool QuerySDKNonDefaultInterface() public int ConstructAndQueryDefaultInterfaceFirstCall() { ClassWithMultipleInterfaces instance2 = new ClassWithMultipleInterfaces(); - return instance2.Property1; + return instance2.DefaultIntProperty; } [Benchmark] public int ConstructAndQueryNonDefaultInterfaceFirstCall() { ClassWithMultipleInterfaces instance2 = new ClassWithMultipleInterfaces(); - return instance2.IntProperty1; + return instance2.IntProperty; } } } \ No newline at end of file diff --git a/Projections/Benchmark/Benchmark.csproj b/Projections/Benchmark/Benchmark.csproj new file mode 100644 index 000000000..180a2694b --- /dev/null +++ b/Projections/Benchmark/Benchmark.csproj @@ -0,0 +1,68 @@ + + + + netstandard2.0;net5.0 + x64;x86 + 10.0.18362.0 + 8 + + + + true + true + 8305;0618 + + + + full + true + + + + + + + + + + + + + + + + + + + + high + $(GeneratedFilesDir)cswinrt_benchmark.rsp + $(CsWinRTExe) %40"$(CsWinRTResponseFile)" + + + +-verbose +-in 10.0.18362.0 +-in @(ReferenceWinMDs->'"%(FullPath)"', ' ') +-out "$(GeneratedFilesDir.TrimEnd('\'))" +-exclude Windows +-include BenchmarkComponent + + + + + + + + + + + + + + + + + + + diff --git a/cswinrt.sln b/cswinrt.sln index e9b85aa6f..41b4794e9 100644 --- a/cswinrt.sln +++ b/cswinrt.sln @@ -54,6 +54,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Nuget", "Nuget", "{5A94EFDF nuget\SignConfig.xml = nuget\SignConfig.xml EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks", "Benchmarks\Benchmarks.csproj", "{B34C96F4-3660-4B2D-8ABD-A4B428166DC7}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BenchmarkComponent", "TestWinRT\BenchmarkComponent\BenchmarkComponent.vcxproj", "{78D85F23-7CB1-44A1-9238-6DF2C76754E4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmark", "Projections\Benchmark\Benchmark.csproj", "{03EEF460-2F10-4FBE-AFFA-53477D3FC8D5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -208,6 +214,48 @@ Global {0A991D5F-BFEE-4D2F-9AAD-6AD06470A5DF}.Release|x64.Build.0 = Release|x64 {0A991D5F-BFEE-4D2F-9AAD-6AD06470A5DF}.Release|x86.ActiveCfg = Release|x86 {0A991D5F-BFEE-4D2F-9AAD-6AD06470A5DF}.Release|x86.Build.0 = Release|x86 + {B34C96F4-3660-4B2D-8ABD-A4B428166DC7}.Debug|Any CPU.ActiveCfg = Debug|x86 + {B34C96F4-3660-4B2D-8ABD-A4B428166DC7}.Debug|ARM.ActiveCfg = Debug|x86 + {B34C96F4-3660-4B2D-8ABD-A4B428166DC7}.Debug|ARM64.ActiveCfg = Debug|x86 + {B34C96F4-3660-4B2D-8ABD-A4B428166DC7}.Debug|x64.ActiveCfg = Debug|x64 + {B34C96F4-3660-4B2D-8ABD-A4B428166DC7}.Debug|x64.Build.0 = Debug|x64 + {B34C96F4-3660-4B2D-8ABD-A4B428166DC7}.Debug|x86.ActiveCfg = Debug|x86 + {B34C96F4-3660-4B2D-8ABD-A4B428166DC7}.Debug|x86.Build.0 = Debug|x86 + {B34C96F4-3660-4B2D-8ABD-A4B428166DC7}.Release|Any CPU.ActiveCfg = Release|x86 + {B34C96F4-3660-4B2D-8ABD-A4B428166DC7}.Release|ARM.ActiveCfg = Release|x86 + {B34C96F4-3660-4B2D-8ABD-A4B428166DC7}.Release|ARM64.ActiveCfg = Release|x86 + {B34C96F4-3660-4B2D-8ABD-A4B428166DC7}.Release|x64.ActiveCfg = Release|x64 + {B34C96F4-3660-4B2D-8ABD-A4B428166DC7}.Release|x64.Build.0 = Release|x64 + {B34C96F4-3660-4B2D-8ABD-A4B428166DC7}.Release|x86.ActiveCfg = Release|x86 + {B34C96F4-3660-4B2D-8ABD-A4B428166DC7}.Release|x86.Build.0 = Release|x86 + {78D85F23-7CB1-44A1-9238-6DF2C76754E4}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {78D85F23-7CB1-44A1-9238-6DF2C76754E4}.Debug|ARM.ActiveCfg = Debug|Win32 + {78D85F23-7CB1-44A1-9238-6DF2C76754E4}.Debug|ARM64.ActiveCfg = Debug|Win32 + {78D85F23-7CB1-44A1-9238-6DF2C76754E4}.Debug|x64.ActiveCfg = Debug|x64 + {78D85F23-7CB1-44A1-9238-6DF2C76754E4}.Debug|x64.Build.0 = Debug|x64 + {78D85F23-7CB1-44A1-9238-6DF2C76754E4}.Debug|x86.ActiveCfg = Debug|Win32 + {78D85F23-7CB1-44A1-9238-6DF2C76754E4}.Debug|x86.Build.0 = Debug|Win32 + {78D85F23-7CB1-44A1-9238-6DF2C76754E4}.Release|Any CPU.ActiveCfg = Release|Win32 + {78D85F23-7CB1-44A1-9238-6DF2C76754E4}.Release|ARM.ActiveCfg = Release|Win32 + {78D85F23-7CB1-44A1-9238-6DF2C76754E4}.Release|ARM64.ActiveCfg = Release|Win32 + {78D85F23-7CB1-44A1-9238-6DF2C76754E4}.Release|x64.ActiveCfg = Release|x64 + {78D85F23-7CB1-44A1-9238-6DF2C76754E4}.Release|x64.Build.0 = Release|x64 + {78D85F23-7CB1-44A1-9238-6DF2C76754E4}.Release|x86.ActiveCfg = Release|Win32 + {78D85F23-7CB1-44A1-9238-6DF2C76754E4}.Release|x86.Build.0 = Release|Win32 + {03EEF460-2F10-4FBE-AFFA-53477D3FC8D5}.Debug|Any CPU.ActiveCfg = Debug|x86 + {03EEF460-2F10-4FBE-AFFA-53477D3FC8D5}.Debug|ARM.ActiveCfg = Debug|x86 + {03EEF460-2F10-4FBE-AFFA-53477D3FC8D5}.Debug|ARM64.ActiveCfg = Debug|x86 + {03EEF460-2F10-4FBE-AFFA-53477D3FC8D5}.Debug|x64.ActiveCfg = Debug|x64 + {03EEF460-2F10-4FBE-AFFA-53477D3FC8D5}.Debug|x64.Build.0 = Debug|x64 + {03EEF460-2F10-4FBE-AFFA-53477D3FC8D5}.Debug|x86.ActiveCfg = Debug|x86 + {03EEF460-2F10-4FBE-AFFA-53477D3FC8D5}.Debug|x86.Build.0 = Debug|x86 + {03EEF460-2F10-4FBE-AFFA-53477D3FC8D5}.Release|Any CPU.ActiveCfg = Release|x86 + {03EEF460-2F10-4FBE-AFFA-53477D3FC8D5}.Release|ARM.ActiveCfg = Release|x86 + {03EEF460-2F10-4FBE-AFFA-53477D3FC8D5}.Release|ARM64.ActiveCfg = Release|x86 + {03EEF460-2F10-4FBE-AFFA-53477D3FC8D5}.Release|x64.ActiveCfg = Release|x64 + {03EEF460-2F10-4FBE-AFFA-53477D3FC8D5}.Release|x64.Build.0 = Release|x64 + {03EEF460-2F10-4FBE-AFFA-53477D3FC8D5}.Release|x86.ActiveCfg = Release|x86 + {03EEF460-2F10-4FBE-AFFA-53477D3FC8D5}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -216,6 +264,7 @@ Global {C6D580C5-7037-4733-B933-916FF400AFE2} = {6D41796B-9904-40B8-BBCB-40B2D1BAE44B} {FFA9A78B-F53F-43EE-AF87-24A80F4C330A} = {6D41796B-9904-40B8-BBCB-40B2D1BAE44B} {0A991D5F-BFEE-4D2F-9AAD-6AD06470A5DF} = {6D41796B-9904-40B8-BBCB-40B2D1BAE44B} + {03EEF460-2F10-4FBE-AFFA-53477D3FC8D5} = {6D41796B-9904-40B8-BBCB-40B2D1BAE44B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {5AE8C9D7-2613-4E1A-A4F2-579BAC28D0A2} From cd3b2f16f2fc2abde751f70b16286418bed3536d Mon Sep 17 00:00:00 2001 From: Manodasan Wignarajah Date: Wed, 1 Jul 2020 11:53:25 -0700 Subject: [PATCH 04/11] Building fixes. --- Benchmarks/Benchmarks.csproj | 4 +++- cswinrt.sln | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Benchmarks/Benchmarks.csproj b/Benchmarks/Benchmarks.csproj index bd31585a1..4552e80ba 100644 --- a/Benchmarks/Benchmarks.csproj +++ b/Benchmarks/Benchmarks.csproj @@ -14,7 +14,7 @@ - + @@ -47,6 +47,8 @@ + + diff --git a/cswinrt.sln b/cswinrt.sln index 41b4794e9..40d1ee8d6 100644 --- a/cswinrt.sln +++ b/cswinrt.sln @@ -57,6 +57,9 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks", "Benchmarks\Benchmarks.csproj", "{B34C96F4-3660-4B2D-8ABD-A4B428166DC7}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BenchmarkComponent", "TestWinRT\BenchmarkComponent\BenchmarkComponent.vcxproj", "{78D85F23-7CB1-44A1-9238-6DF2C76754E4}" + ProjectSection(ProjectDependencies) = postProject + {6ACFD2B2-E8AA-4CD4-AAD8-213CE8BB2637} = {6ACFD2B2-E8AA-4CD4-AAD8-213CE8BB2637} + EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmark", "Projections\Benchmark\Benchmark.csproj", "{03EEF460-2F10-4FBE-AFFA-53477D3FC8D5}" EndProject From 669484c4c980a0b2875b6b020c336dd86bd4ebee Mon Sep 17 00:00:00 2001 From: Manodasan Wignarajah Date: Wed, 1 Jul 2020 13:32:23 -0700 Subject: [PATCH 05/11] Remove unnecessary removals. --- Projections/Benchmark/Benchmark.csproj | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Projections/Benchmark/Benchmark.csproj b/Projections/Benchmark/Benchmark.csproj index 180a2694b..26aa10a43 100644 --- a/Projections/Benchmark/Benchmark.csproj +++ b/Projections/Benchmark/Benchmark.csproj @@ -30,8 +30,6 @@ - - @@ -59,9 +57,9 @@ - - + + From e30070602e0508549340819e45ee7eb7a0eb7034 Mon Sep 17 00:00:00 2001 From: Manodasan Wignarajah Date: Wed, 1 Jul 2020 13:55:40 -0700 Subject: [PATCH 06/11] Fix PlatformVersion error when building benchmarks due to Window identifier set. --- Directory.Build.props | 1 + 1 file changed, 1 insertion(+) diff --git a/Directory.Build.props b/Directory.Build.props index 573d6c7eb..f8dd4e42b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -42,6 +42,7 @@ Windows + 10.0.18362.0 From 661a2da5b5ed222d577579976f544270e75dbe52 Mon Sep 17 00:00:00 2001 From: Manodasan Wignarajah Date: Wed, 1 Jul 2020 14:06:27 -0700 Subject: [PATCH 07/11] Updating to include benchmarkcomponent from testwinrt. --- get_testwinrt.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get_testwinrt.cmd b/get_testwinrt.cmd index 971973dc6..d78f9490d 100644 --- a/get_testwinrt.cmd +++ b/get_testwinrt.cmd @@ -12,7 +12,7 @@ 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 427f66c2cd0837e81005a840472b0ef1a1d8639d +git reset -q --hard 6d72afbcb51ab3981c6cd620d24954020f4d2bbc if ErrorLevel 1 popd & exit /b !ErrorLevel! echo Restoring Nuget ..\.nuget\nuget.exe restore From 8d8c3976375e2265f5b7fe6e004dab10fb8558b6 Mon Sep 17 00:00:00 2001 From: Manodasan Wignarajah Date: Wed, 1 Jul 2020 15:26:50 -0700 Subject: [PATCH 08/11] Fix absolute paths --- benchmark.cmd | 2 +- benchmark_winmd.cmd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmark.cmd b/benchmark.cmd index 7b2f42e7a..4ebba8bd6 100644 --- a/benchmark.cmd +++ b/benchmark.cmd @@ -1,2 +1,2 @@ msbuild Benchmarks\Benchmarks.csproj -t:restore -t:build /p:platform=x64 /p:configuration=release -dotnet S:\CsWinRT\Benchmarks\bin\x64\Release\netcoreapp2.0\Benchmarks.dll -filter * --runtimes netcoreapp2.0 netcoreapp3.1 netcoreapp5.0 \ No newline at end of file +dotnet %~dp0Benchmarks\bin\x64\Release\netcoreapp2.0\Benchmarks.dll -filter * --runtimes netcoreapp2.0 netcoreapp3.1 netcoreapp5.0 \ No newline at end of file diff --git a/benchmark_winmd.cmd b/benchmark_winmd.cmd index e2d5c03aa..feaa12298 100644 --- a/benchmark_winmd.cmd +++ b/benchmark_winmd.cmd @@ -1,4 +1,4 @@ msbuild Benchmarks\Benchmarks.csproj -t:restore -t:clean;rebuild /p:BenchmarkWinmdSupport=true /p:platform=x64 /p:configuration=release /p:TargetFramework=netcoreapp3.1 -S:\CsWinRT\Benchmarks\bin\x64\Release\netcoreapp3.1\Benchmarks.exe -filter * +%~dp0Benchmarks\bin\x64\Release\netcoreapp3.1\Benchmarks.exe -filter * rem Clean project to prevent mismatch scenarios with the typical benchmark.cmd scenario. msbuild Benchmarks\Benchmarks.csproj -t:restore -t:clean /p:BenchmarkWinmdSupport=true /p:platform=x64 /p:configuration=release /p:TargetFramework=netcoreapp3.1 >nul \ No newline at end of file From f677bbb88a47fc68742449622271851bfa1b80a0 Mon Sep 17 00:00:00 2001 From: Manodasan Wignarajah Date: Wed, 1 Jul 2020 19:02:57 -0700 Subject: [PATCH 09/11] Update readme and comments. --- Benchmarks/Program.cs | 8 ++++---- README.md | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Benchmarks/Program.cs b/Benchmarks/Program.cs index 03a29cf41..f1c3b4d24 100644 --- a/Benchmarks/Program.cs +++ b/Benchmarks/Program.cs @@ -33,8 +33,8 @@ public CustomConfig() // Test WinMD support #if NETCOREAPP3_1 - // BenchmarkDotNet will rebuild the project with a project reference when this exe is ran and - // in the same folder as it we have the application manifest binplaced which we want to embed in the new exe. + // BenchmarkDotNet will rebuild the project with a project reference to this project when this project's output exe is ran. It + // will be ran from the same folder as where we have the application manifest binplaced which we want to embed in the new exe. string manifestFile = Path.Combine( Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "Benchmarks.manifest"); @@ -62,8 +62,8 @@ public CustomConfig() // Custom tool chain for building the benchmark with WinMDs as we need to execute the // exe version of the benchmark rather than the dll version which runs under dotnet cli. - // This is becuase we need to be able to embed a side by side manifest for reg free winrt - // and to enable COM to find the WinMDs. + // This is because we need to be able to embed a side by side manifest for reg free winrt + // and we need COM to be able to find the WinMDs. private class NetCore3ToolChainWithNativeExecution : Toolchain { public NetCore3ToolChainWithNativeExecution() diff --git a/README.md b/README.md index 0836f9f0d..e1286a1df 100644 --- a/README.md +++ b/README.md @@ -117,12 +117,16 @@ The **/TestComponentCSharp** folder contains an implementation of a WinRT test c ## /Projections -The **/Projections** folder contains several projects for generating and building projections from the Windows SDK, WinUI, and Test metadata (produced by the TestWinRT and TestComponentCSharp projects). +The **/Projections** folder contains several projects for generating and building projections from the Windows SDK, WinUI, Benchmark (produced by the BenchmarkComponent project), and Test metadata (produced by the TestWinRT and TestComponentCSharp projects). ## /UnitTest The **/UnitTest** folder contains unit tests for validating the Windows SDK, WinUI, and Test projections generated above. All pull requests should ensure that this project executes without errors. +## /Benchmarks + +The **/Benchmarks** folder contains benchmarks written using BenchmarkDotNet to track the performance of scenarios in the generated projection. To run the benchmarks using the CsWinRT projection, run **benchmark.cmd**. To run the same benchmarks using the built-in WinMD support in NET Core 3.1 to compare against as a basline, run **benchmark_winmd.cmd**. + ## /WinUIDesktopSample The **/WinUIDesktopSample** contains an end-to-end sample app that uses the Windows SDK and WinUI projections generated above. From e686b736ced1f6277fd1a1b1d79e1183dfa394a7 Mon Sep 17 00:00:00 2001 From: Manodasan Wignarajah Date: Wed, 1 Jul 2020 19:26:17 -0700 Subject: [PATCH 10/11] Fix typo. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e1286a1df..f9e6ff868 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ The **/UnitTest** folder contains unit tests for validating the Windows SDK, Win ## /Benchmarks -The **/Benchmarks** folder contains benchmarks written using BenchmarkDotNet to track the performance of scenarios in the generated projection. To run the benchmarks using the CsWinRT projection, run **benchmark.cmd**. To run the same benchmarks using the built-in WinMD support in NET Core 3.1 to compare against as a basline, run **benchmark_winmd.cmd**. +The **/Benchmarks** folder contains benchmarks written using BenchmarkDotNet to track the performance of scenarios in the generated projection. To run the benchmarks using the CsWinRT projection, run **benchmark.cmd**. To run the same benchmarks using the built-in WinMD support in NET Core 3.1 to compare against as a baseline, run **benchmark_winmd.cmd**. ## /WinUIDesktopSample From 521b9579168ce7e7d8b53e87b75fd6508edf9caf Mon Sep 17 00:00:00 2001 From: Manodasan Wignarajah Date: Wed, 8 Jul 2020 15:15:26 -0700 Subject: [PATCH 11/11] PR feedback. --- Benchmarks/Program.cs | 3 +-- Projections/Benchmark/Benchmark.csproj | 1 - Projections/Test/Test.csproj | 1 - Projections/WinUI/WinUI.csproj | 1 - Projections/Windows/Windows.csproj | 1 - 5 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Benchmarks/Program.cs b/Benchmarks/Program.cs index f1c3b4d24..89255f080 100644 --- a/Benchmarks/Program.cs +++ b/Benchmarks/Program.cs @@ -26,8 +26,7 @@ public CustomConfig() .WithPlatform(BenchmarkDotNet.Environments.Platform.X64) .WithArguments( new Argument[] { - new MsBuildArgument("/p:platform=x64"), - new MsBuildArgument("/p:MsAppxPackageTargets=%temp%\\EmptyMsAppxPackage.Targets") + new MsBuildArgument("/p:platform=x64") } ).AsDefault(); diff --git a/Projections/Benchmark/Benchmark.csproj b/Projections/Benchmark/Benchmark.csproj index 26aa10a43..02265c124 100644 --- a/Projections/Benchmark/Benchmark.csproj +++ b/Projections/Benchmark/Benchmark.csproj @@ -3,7 +3,6 @@ netstandard2.0;net5.0 x64;x86 - 10.0.18362.0 8 diff --git a/Projections/Test/Test.csproj b/Projections/Test/Test.csproj index 803485d94..399e05808 100644 --- a/Projections/Test/Test.csproj +++ b/Projections/Test/Test.csproj @@ -3,7 +3,6 @@ netstandard2.0;net5.0 x64;x86 - 10.0.18362.0 8 diff --git a/Projections/WinUI/WinUI.csproj b/Projections/WinUI/WinUI.csproj index 7d072ba81..7d5287727 100644 --- a/Projections/WinUI/WinUI.csproj +++ b/Projections/WinUI/WinUI.csproj @@ -3,7 +3,6 @@ netstandard2.0;net5.0 x64;x86 - 10.0.18362.0 8 diff --git a/Projections/Windows/Windows.csproj b/Projections/Windows/Windows.csproj index fd75e76b9..8d96377ee 100644 --- a/Projections/Windows/Windows.csproj +++ b/Projections/Windows/Windows.csproj @@ -3,7 +3,6 @@ netstandard2.0;net5.0 x64;x86 - 10.0.18362.0 8