Skip to content

Commit

Permalink
Upgrade BenchmarkDotNet to the version 0.7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyAkinshin committed May 16, 2015
1 parent ea095e1 commit f5545bc
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 38 deletions.
4 changes: 2 additions & 2 deletions Basic/08_unmanagedPoolPerf/08_unmanagedPoolPerf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="BenchmarkDotNet, Version=0.7.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\BenchmarkDotNet.0.7.1\lib\net35\BenchmarkDotNet.dll</HintPath>
<Reference Include="BenchmarkDotNet, Version=0.7.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\BenchmarkDotNet.0.7.4\lib\net35\BenchmarkDotNet.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down
36 changes: 13 additions & 23 deletions Basic/08_unmanagedPoolPerf/Competition.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using BenchmarkDotNet.Tasks;

namespace UnmanagedPoolPerfSample
namespace UnmanagedPoolPerfSample
{
using System;
using System.Runtime.CLR;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet;
using BenchmarkDotNet.Tasks;

[Task(platform: BenchmarkPlatform.X86, jitVersion: BenchmarkJitVersion.LegacyJit)]
public class Competition
Expand All @@ -31,40 +30,31 @@ public override string ToString()
}
}

const int N = 50001, Iter = 701;
const int N = 50001;
readonly UnmanagedHeap<Customer> heap = new UnmanagedHeap<Customer>(N);

[Benchmark("Ctor call via reflection (on already allocated memory)")]
public void Reflection()
{
for (int j = 0; j < Iter; j++)
{
for (int i = 0; i < N; i++)
heap.AllocatePure();
heap.Reset();
}
for (int i = 0; i < N; i++)
heap.AllocatePure();
heap.Reset();
}

[Benchmark("Ctor call via method body ptr redirection")]
public void MethodBodyPtr()
{
for (int j = 0; j < Iter; j++)
{
for (int i = 0; i < N; i++)
heap.Allocate();
heap.Reset();
}
for (int i = 0; i < N; i++)
heap.Allocate();
heap.Reset();
}

[Benchmark("Pure allocation in managed memory")]
public void PureAllocation()
{
for (int j = 0; j < Iter; j++)
{
for (int i = 0; i < N; i++)
new Customer(123);
GC.Collect();
}
for (int i = 0; i < N; i++)
new Customer(123);
GC.Collect();
}
}
}
2 changes: 1 addition & 1 deletion Basic/08_unmanagedPoolPerf/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static void Main(string[] args)
var competitionSwitch = new BenchmarkCompetitionSwitch(new[] {
typeof(Competition)
});
competitionSwitch.Run(args);
competitionSwitch.Run(new[] { "Competition" });
}
}
}
2 changes: 1 addition & 1 deletion Basic/08_unmanagedPoolPerf/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BenchmarkDotNet" version="0.7.1" targetFramework="net4" userInstalled="true" />
<package id="BenchmarkDotNet" version="0.7.4" targetFramework="net35" userInstalled="true" />
</packages>
6 changes: 4 additions & 2 deletions Basic/09_directCastPerf/09_directCastPerf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="BenchmarkDotNet">
<HintPath>..\..\packages\BenchmarkDotNet.0.5.2\lib\net35\BenchmarkDotNet.dll</HintPath>
<Reference Include="BenchmarkDotNet, Version=0.7.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\BenchmarkDotNet.0.7.4\lib\net35\BenchmarkDotNet.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityPtr">
<HintPath>..\..\libs\EntityPtr.dll</HintPath>
Expand All @@ -53,6 +54,7 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
21 changes: 12 additions & 9 deletions Basic/09_directCastPerf/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ class Program
{
static void Main(string[] args)
{
new Competition().Run();
var competitionSwitch = new BenchmarkCompetitionSwitch(new[] {
typeof(Competition)
});
competitionSwitch.Run(new[] { "Competition" });
Console.ReadKey();
}
}
Expand All @@ -20,12 +23,12 @@ internal class C : B { }
internal class D : C { }
internal class E : D { }

class Competition : BenchmarkCompetition
public class Competition
{
const int Iter = 10000001;
private object obj;

[BenchmarkMethod("JIT provided casting to inherited class deep = 5")]
[Benchmark("JIT provided casting to inherited class deep = 5")]
[MethodImpl(MethodImplOptions.NoOptimization)]
public void JitProvidedFar()
{
Expand All @@ -37,7 +40,7 @@ public void JitProvidedFar()
}
}

[BenchmarkMethod("JetCast casting to inherited class deep = 5")]
[Benchmark("JetCast casting to inherited class deep = 5")]
[MethodImpl(MethodImplOptions.NoOptimization)]
public void CastRefProvidedFar()
{
Expand All @@ -49,7 +52,7 @@ public void CastRefProvidedFar()
}
}

[BenchmarkMethod("JIT provided casting to inherited class deep = 2")]
[Benchmark("JIT provided casting to inherited class deep = 2")]
[MethodImpl(MethodImplOptions.NoOptimization)]
public void JitProvidedNear()
{
Expand All @@ -61,7 +64,7 @@ public void JitProvidedNear()
}
}

[BenchmarkMethod("JetCast casting to inherited class deep = 2")]
[Benchmark("JetCast casting to inherited class deep = 2")]
[MethodImpl(MethodImplOptions.NoOptimization)]
public void CastRefProvidedNear()
{
Expand All @@ -73,7 +76,7 @@ public void CastRefProvidedNear()
}
}

[BenchmarkMethod("JIT provided casting to inherited class deep = 1")]
[Benchmark("JIT provided casting to inherited class deep = 1")]
[MethodImpl(MethodImplOptions.NoOptimization)]
public void JitProvidedEq()
{
Expand All @@ -85,7 +88,7 @@ public void JitProvidedEq()
}
}

[BenchmarkMethod("JetCast casting to inherited class deep = 1")]
[Benchmark("JetCast casting to inherited class deep = 1")]
[MethodImpl(MethodImplOptions.NoOptimization)]
public void CastRefProvidedEq()
{
Expand All @@ -97,7 +100,7 @@ public void CastRefProvidedEq()
}
}

[BenchmarkMethod("No casting")]
[Benchmark("No casting")]
[MethodImpl(MethodImplOptions.NoOptimization)]
public void NoCast()
{
Expand Down
4 changes: 4 additions & 0 deletions Basic/09_directCastPerf/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BenchmarkDotNet" version="0.7.4" targetFramework="net45" userInstalled="true" />
</packages>

0 comments on commit f5545bc

Please sign in to comment.