-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add .NET 8 and test for performance/regressions
- Loading branch information
Showing
15 changed files
with
135 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Correlate.DependencyInjection/Correlate.DependencyInjection.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 5 additions & 3 deletions
8
test/Correlate.AspNetCore.Tests/Correlate.AspNetCore.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFrameworks>net7.0;net6.0</TargetFrameworks> | ||
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsTestProject>false</IsTestProject> | ||
<Baseline>true</Baseline> | ||
<CurrentVersion>true</CurrentVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.10" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Correlate.AspNetCore\Correlate.AspNetCore.csproj" Condition="'$(Baseline)'=='true'" /> | ||
<ProjectReference Include="..\..\src\Correlate.DependencyInjection\Correlate.DependencyInjection.csproj" Condition="'$(Baseline)'=='true'" /> | ||
<ProjectReference Include="..\..\src\Correlate.AspNetCore\Correlate.AspNetCore.csproj" Condition="'$(CurrentVersion)'=='true'" /> | ||
<ProjectReference Include="..\..\src\Correlate.DependencyInjection\Correlate.DependencyInjection.csproj" Condition="'$(CurrentVersion)'=='true'" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,104 @@ | ||
using BenchmarkDotNet.Configs; | ||
using System.Reflection; | ||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Environments; | ||
using BenchmarkDotNet.Jobs; | ||
using BenchmarkDotNet.Order; | ||
using BenchmarkDotNet.Running; | ||
using BenchmarkDotNet.Toolchains; | ||
using BenchmarkDotNet.Toolchains.CsProj; | ||
using Correlate.Benchmarks; | ||
|
||
IToolchain[] toolchains = { CsProjCoreToolchain.NetCoreApp70, CsProjCoreToolchain.NetCoreApp60 }; | ||
Runtime mostCurrentRuntime = CoreRuntime.Core80; | ||
IToolchain mostCurrentToolchain = CsProjCoreToolchain.NetCoreApp80; | ||
|
||
IConfig cfg = DefaultConfig.Instance | ||
.ForAllToolchains(toolchains, Job.Default.WithId("Current"), toolchain => toolchain.Equals(CsProjCoreToolchain.NetCoreApp70)) | ||
.ForAllToolchains(toolchains, | ||
Job.Default | ||
.WithId("4.0.0") | ||
.WithToolchain(CsProjCoreToolchain.NetCoreApp70) | ||
.WithNuGet("Correlate.AspNetCore", "4.0.0") | ||
.WithNuGet("Correlate.DependencyInjection", "4.0.0") | ||
.WithArguments(new[] { new MsBuildArgument("/p:Baseline=false") }) | ||
); | ||
Version[] versions = | ||
{ | ||
new("4.0.0"), new("5.1.0"), new("0.0.0") // Current | ||
}; | ||
|
||
IEnumerable<(Runtime, IToolchain)> runtimes = ConfigExtensions.GetRuntimes(args); | ||
IEnumerable<(Version version, Runtime runtime, IToolchain toolchain)> runs = | ||
( | ||
from version in versions | ||
from runtime in runtimes | ||
orderby version descending, runtime.Item1.ToString() descending | ||
select (version, runtime.Item1, runtime.Item2) | ||
).ToList(); | ||
|
||
#if RELEASE | ||
BenchmarkRunner.Run<AspNetCoreBenchmark>(cfg); | ||
IConfig cfg = DefaultConfig.Instance; | ||
#else | ||
BenchmarkRunner.Run<AspNetCoreBenchmark>(new DebugInProcessConfig()); | ||
IConfig cfg = new DebugInProcessConfig(); | ||
#endif | ||
cfg = runs.Aggregate(cfg, | ||
(current, run) => current | ||
.ForAllRuntimes( | ||
run.version, | ||
run.runtime, | ||
run.toolchain, | ||
(runtime, toolchain) => runtime.Equals(mostCurrentRuntime) && toolchain.Equals(mostCurrentToolchain)) | ||
); | ||
|
||
cfg.WithOrderer(new DefaultOrderer(SummaryOrderPolicy.Declared)); | ||
|
||
BenchmarkRunner.Run<AspNetCoreBenchmark>(cfg); | ||
|
||
internal static class ConfigExtensions | ||
{ | ||
public static IConfig ForAllToolchains(this IConfig config, IEnumerable<IToolchain> toolchains, Job job, Func<IToolchain, bool>? isBaseline = null) | ||
public static IReadOnlyCollection<(Runtime, IToolchain)> GetRuntimes(string[] args) | ||
{ | ||
foreach (IToolchain toolchain in toolchains) | ||
const BindingFlags bf = BindingFlags.Public | BindingFlags.Static; | ||
|
||
var argRuntimes = args | ||
.SkipWhile(arg => arg == "--runtimes") | ||
.TakeWhile(arg => arg.StartsWith("net")) | ||
.ToHashSet(StringComparer.OrdinalIgnoreCase); | ||
|
||
IEnumerable<Runtime> runtimes = typeof(CoreRuntime).GetFields(bf) | ||
.Union(typeof(ClrRuntime).GetFields(bf)) | ||
.Select(fi => fi.GetValue(null)) | ||
.OfType<Runtime>() | ||
.Where(rt => argRuntimes.Contains(rt.RuntimeMoniker.ToString())) | ||
.ToList(); | ||
|
||
IEnumerable<CsProjCoreToolchain> toolchains = typeof(CsProjCoreToolchain).GetFields(bf) | ||
.Select(fi => fi.GetValue(null)) | ||
.OfType<CsProjCoreToolchain>() | ||
.ToList(); | ||
|
||
return runtimes | ||
.Select(rt => (rt, (IToolchain)toolchains.Single(tc => ((CsProjGenerator)tc.Generator).TargetFrameworkMoniker == rt.MsBuildMoniker))) | ||
.ToList(); | ||
} | ||
|
||
public static IConfig ForAllRuntimes(this IConfig config, Version version, Runtime runtime, IToolchain toolchain, Func<Runtime, IToolchain, bool> isBaselineRuntime) | ||
{ | ||
bool isCurrentVersion = version.Major == 0; | ||
string label = isCurrentVersion | ||
? "vNext" | ||
: $"v{version.ToString(3)}"; | ||
|
||
Job job = JobMode<Job>.Default | ||
.WithRuntime(runtime) | ||
.WithToolchain(toolchain) | ||
.WithId(label); | ||
|
||
if (!isCurrentVersion) | ||
{ | ||
job = job | ||
.WithNuGet("Correlate.AspNetCore", version.ToString(3)) | ||
.WithNuGet("Correlate.DependencyInjection", version.ToString(3)) | ||
.WithArguments(new[] { new MsBuildArgument("/p:CurrentVersion=false") }); | ||
} | ||
else | ||
{ | ||
Job j = job.WithToolchain(toolchain); | ||
config = config.AddJob(isBaseline?.Invoke(toolchain) ?? false ? j.AsBaseline() : j); | ||
if (isBaselineRuntime(runtime, toolchain)) | ||
{ | ||
job = job.AsBaseline(); | ||
} | ||
} | ||
|
||
return config; | ||
Console.WriteLine($"{version} {runtime} {isBaselineRuntime(runtime, toolchain)}"); | ||
return config.AddJob(job); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,31 @@ | ||
# Benchmark results | ||
|
||
``` | ||
BenchmarkDotNet v0.13.7, Windows 10 (10.0.19045.3324/22H2/2022Update) | ||
BenchmarkDotNet v0.13.10, Windows 10 (10.0.19045.3693/22H2/2022Update) | ||
Intel Core i7-8700K CPU 3.70GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores | ||
.NET SDK 7.0.400 | ||
[Host] : .NET 7.0.10 (7.0.1023.36312), X64 RyuJIT AVX2 | ||
4.0.0 : .NET 6.0.21 (6.0.2123.36311), X64 RyuJIT AVX2 | ||
Current : .NET 6.0.21 (6.0.2123.36311), X64 RyuJIT AVX2 | ||
.NET SDK 8.0.100 | ||
[Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2 | ||
v4.0.0 : .NET 6.0.25 (6.0.2523.51912), X64 RyuJIT AVX2 | ||
v5.1.0 : .NET 6.0.25 (6.0.2523.51912), X64 RyuJIT AVX2 | ||
vNext : .NET 6.0.25 (6.0.2523.51912), X64 RyuJIT AVX2 | ||
``` | ||
|
||
| Method | Job | Arguments | NuGetReferences | Toolchain | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | | ||
|-------- |-------- |------------------ |--------------------------------------------------------------- |---------- |---------:|--------:|--------:|------:|--------:|-------:|----------:|------------:| | ||
| ApiCall | 4.0.0 | /p:Baseline=false | Correlate.AspNetCore 4.0.0,Correlate.DependencyInjection 4.0.0 | .NET 6.0 | 148.2 us | 1.95 us | 1.73 us | 1.02 | 0.02 | 0.4883 | 4.33 KB | 1.11 | | ||
| ApiCall | 4.0.0 | /p:Baseline=false | Correlate.AspNetCore 4.0.0,Correlate.DependencyInjection 4.0.0 | .NET 7.0 | 148.1 us | 0.93 us | 0.87 us | 1.02 | 0.01 | 0.4883 | 4.06 KB | 1.04 | | ||
| ApiCall | Current | Default | Default | .NET 6.0 | 140.2 us | 1.12 us | 1.05 us | 0.96 | 0.01 | 0.4883 | 4.16 KB | 1.07 | | ||
| ApiCall | Current | Default | Default | .NET 7.0 | 145.8 us | 1.07 us | 1.00 us | 1.00 | 0.00 | 0.4883 | 3.91 KB | 1.00 | | ||
| Method | Job | Runtime | Arguments | NuGetReferences | Mean | Error | StdDev | Median | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | | ||
|-------- |------- |--------- |------------------------ |--------------------------------------------------------------- |---------:|--------:|--------:|---------:|------:|--------:|-------:|----------:|------------:| | ||
| ApiCall | v4.0.0 | .NET 6.0 | /p:CurrentVersion=false | Correlate.AspNetCore 4.0.0,Correlate.DependencyInjection 4.0.0 | 202.2 us | 3.80 us | 8.02 us | 199.1 us | 1.14 | 0.04 | 0.9766 | 6.17 KB | 1.27 | | ||
| ApiCall | v4.0.0 | .NET 7.0 | /p:CurrentVersion=false | Correlate.AspNetCore 4.0.0,Correlate.DependencyInjection 4.0.0 | 203.7 us | 1.64 us | 1.46 us | 203.9 us | 1.09 | 0.01 | 0.4883 | 5.93 KB | 1.22 | | ||
| ApiCall | v4.0.0 | .NET 8.0 | /p:CurrentVersion=false | Correlate.AspNetCore 4.0.0,Correlate.DependencyInjection 4.0.0 | 199.7 us | 3.61 us | 5.06 us | 200.7 us | 1.06 | 0.03 | 0.4883 | 5.73 KB | 1.18 | | ||
| ApiCall | v5.1.0 | .NET 6.0 | /p:CurrentVersion=false | Correlate.AspNetCore 5.1.0,Correlate.DependencyInjection 5.1.0 | 189.4 us | 2.26 us | 2.12 us | 189.2 us | 1.02 | 0.01 | 0.7324 | 5.25 KB | 1.08 | | ||
| ApiCall | v5.1.0 | .NET 7.0 | /p:CurrentVersion=false | Correlate.AspNetCore 5.1.0,Correlate.DependencyInjection 5.1.0 | 201.0 us | 0.93 us | 0.83 us | 201.1 us | 1.08 | 0.01 | 0.4883 | 5.04 KB | 1.04 | | ||
| ApiCall | v5.1.0 | .NET 8.0 | /p:CurrentVersion=false | Correlate.AspNetCore 5.1.0,Correlate.DependencyInjection 5.1.0 | 185.9 us | 1.40 us | 1.31 us | 185.6 us | 1.00 | 0.01 | 0.4883 | 4.87 KB | 1.00 | | ||
| ApiCall | vNext | .NET 6.0 | Default | Default | 191.3 us | 1.71 us | 1.60 us | 191.3 us | 1.03 | 0.01 | 0.7324 | 5.25 KB | 1.08 | | ||
| ApiCall | vNext | .NET 7.0 | Default | Default | 205.1 us | 4.08 us | 4.85 us | 204.4 us | 1.11 | 0.03 | 0.4883 | 5.04 KB | 1.04 | | ||
| ApiCall | vNext | .NET 8.0 | Default | Default | 186.5 us | 1.90 us | 1.78 us | 186.5 us | 1.00 | 0.00 | 0.4883 | 4.87 KB | 1.00 | | ||
|
||
### CLI | ||
|
||
To run the benchmark: | ||
``` | ||
cd ./test/Correlate.Benchmarks | ||
dotnet run -c Release -f net7.0 net6.0 | ||
dotnet run -c Release -f net8.0 --runtimes net80 net70 net60 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/Correlate.DependencyInjection.Tests/Correlate.DependencyInjection.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters