Skip to content

Commit

Permalink
Benchmarks comparing to original
Browse files Browse the repository at this point in the history
  • Loading branch information
jtmueller committed Dec 29, 2021
1 parent abe514f commit 3a7c973
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 3 deletions.
18 changes: 15 additions & 3 deletions D2SLib.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30711.63
# Visual Studio Version 17
VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "D2SLib", "src\D2SLib.csproj", "{BA0A2A07-363C-4284-87C9-71F1349F0583}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D2SLibTests", "test\D2SLibTests.csproj", "{F2F223AD-BCE4-47B3-BAF8-DA2D533FD05F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "D2SLibTests", "test\D2SLibTests.csproj", "{F2F223AD-BCE4-47B3-BAF8-DA2D533FD05F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D2SLib_Local.Benchmark", "benchmarks\D2SLib_Local.Benchmark\D2SLib_Local.Benchmark.csproj", "{3F72860B-D08C-45EE-9E1B-17888E103B62}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D2SLib_Nuget.Benchmark", "benchmarks\D2SLib_Nuget.Benchmark\D2SLib_Nuget.Benchmark.csproj", "{7D3FEEAB-7752-4753-9EC0-EF4E7F72EB74}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -21,6 +25,14 @@ Global
{F2F223AD-BCE4-47B3-BAF8-DA2D533FD05F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2F223AD-BCE4-47B3-BAF8-DA2D533FD05F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2F223AD-BCE4-47B3-BAF8-DA2D533FD05F}.Release|Any CPU.Build.0 = Release|Any CPU
{3F72860B-D08C-45EE-9E1B-17888E103B62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F72860B-D08C-45EE-9E1B-17888E103B62}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F72860B-D08C-45EE-9E1B-17888E103B62}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F72860B-D08C-45EE-9E1B-17888E103B62}.Release|Any CPU.Build.0 = Release|Any CPU
{7D3FEEAB-7752-4753-9EC0-EF4E7F72EB74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7D3FEEAB-7752-4753-9EC0-EF4E7F72EB74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7D3FEEAB-7752-4753-9EC0-EF4E7F72EB74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7D3FEEAB-7752-4753-9EC0-EF4E7F72EB74}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
28 changes: 28 additions & 0 deletions benchmarks/D2SLib_Local.Benchmark/BenchmarkConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Exporters;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Loggers;

namespace D2SLib_Benchmark;

internal class BenchmarkConfig : ManualConfig
{
public BenchmarkConfig()
{
AddJob(Job.Default
.WithRuntime(CoreRuntime.Core60)
.WithPlatform(Platform.X64)
.WithJit(Jit.RyuJit));
AddJob(Job.Default
.WithRuntime(CoreRuntime.Core31)
.WithPlatform(Platform.X64)
.WithJit(Jit.RyuJit));
AddDiagnoser(MemoryDiagnoser.Default);
//AddExporter(CsvMeasurementsExporter.Default);
//AddExporter(HtmlExporter.Default);
AddExporter(MarkdownExporter.GitHub);
AddLogger(ConsoleLogger.Default);
}
}
27 changes: 27 additions & 0 deletions benchmarks/D2SLib_Local.Benchmark/D2SLib_Local.Benchmark.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
<LangVersion>10</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>D2SLib_Benchmark</RootNamespace>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\test\Resources\**\*">
<Link>Resources\%(RecursiveDir)\%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\D2SLib.csproj" />
</ItemGroup>

</Project>
22 changes: 22 additions & 0 deletions benchmarks/D2SLib_Local.Benchmark/LoadGame.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using BenchmarkDotNet.Attributes;
using D2SLib;

namespace D2SLib_Benchmark;

[Config(typeof(BenchmarkConfig))]
public class LoadGame
{
private byte[] _saveData = Array.Empty<byte>();

[Benchmark]
public void LoadComplexSave()
{
_ = Core.ReadD2S(_saveData);
}

[GlobalSetup]
public void GlobalSetup()
{
_saveData = File.ReadAllBytes(@"Resources\D2S\1.15\DannyIsGreat.d2s");
}
}
3 changes: 3 additions & 0 deletions benchmarks/D2SLib_Local.Benchmark/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using BenchmarkDotNet.Running;

BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
29 changes: 29 additions & 0 deletions benchmarks/D2SLib_Nuget.Benchmark/D2SLib_Nuget.Benchmark.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
<LangVersion>10</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>D2SLib_Benchmark</RootNamespace>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\test\Resources\**\*">
<Link>Resources\%(RecursiveDir)\%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<Compile Include="..\D2SLib_Local.Benchmark\BenchmarkConfig.cs" Link="BenchmarkConfig.cs" />
<Compile Include="..\D2SLib_Local.Benchmark\LoadGame.cs" Link="LoadGame.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
<PackageReference Include="D2SLib" Version="1.0.2" />
</ItemGroup>

</Project>
3 changes: 3 additions & 0 deletions benchmarks/D2SLib_Nuget.Benchmark/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using BenchmarkDotNet.Running;

BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
14 changes: 14 additions & 0 deletions benchmarks/Results.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Original, load complex save:

| Method | Job | Runtime | Mean | Error | StdDev | Allocated |
|---------------- |----------- |-------------- |---------:|--------:|--------:|----------:|
| LoadComplexSave | Job-SSHODX | .NET 6.0 | 171.1 ms | 3.40 ms | 7.67 ms | 1 MB |
| LoadComplexSave | Job-AEQOGU | .NET Core 3.1 | 170.7 ms | 3.39 ms | 7.51 ms | 1 MB |

Revised, load same save:

| Method | Job | Runtime | Mean | Error | StdDev | Gen 0 | Gen 1 | Allocated |
|---------------- |----------- |-------------- |---------:|----------:|----------:|--------:|-------:|----------:|
| LoadComplexSave | Job-KBRNVU | .NET 6.0 | 1.359 ms | 0.0175 ms | 0.0163 ms | 23.4375 | 3.9063 | 115 KB |
| LoadComplexSave | Job-ALJOBF | .NET Core 3.1 | 2.148 ms | 0.0180 ms | 0.0168 ms | 23.4375 | 3.9063 | 115 KB |

0 comments on commit 3a7c973

Please sign in to comment.