-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a benchmarkdotnet project and added a CloneProviderBenchmark cl…
…ass to it which can be run from the commandline
- Loading branch information
Showing
5 changed files
with
71 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using BenchmarkDotNet.Attributes; | ||
using Duality.Cloning; | ||
using Duality.Tests.Serialization; | ||
|
||
namespace DualityBenchmarks | ||
{ | ||
public class CloneProviderBenchmarks | ||
{ | ||
[Benchmark] | ||
public void CloneTestObjectGraph() | ||
{ | ||
Random rnd = new Random(0); | ||
TestObject data = new TestObject(rnd, 5); | ||
TestObject[] results = new TestObject[200]; | ||
|
||
for (int i = 0; i < results.Length; i++) | ||
{ | ||
results[i] = data.DeepClone(); | ||
} | ||
} | ||
|
||
[Benchmark(Baseline = true)] | ||
public void CreateWithoutClone() | ||
{ | ||
Random rnd = new Random(0); | ||
TestObject[] results = new TestObject[200]; | ||
for (int i = 0; i < results.Length; i++) | ||
{ | ||
results[i] = new TestObject(rnd, 5); | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net472</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Source\Core\Duality\Duality.csproj" /> | ||
<ProjectReference Include="..\..\Test\Core\DualityTests.csproj" /> | ||
</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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using BenchmarkDotNet.Running; | ||
|
||
namespace DualityBenchmarks | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); | ||
} | ||
} | ||
} |
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