-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1520 from Aaronontheweb/nbench-integration
added initial performance specs using NBench
- Loading branch information
Showing
16 changed files
with
399 additions
and
9 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
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
82 changes: 82 additions & 0 deletions
82
src/core/Akka.Tests.Performance/Actor/ActorMemoryFootprintSpec.cs
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,82 @@ | ||
using System; | ||
using Akka.Actor; | ||
using Akka.Util.Internal; | ||
using NBench; | ||
|
||
namespace Akka.Tests.Performance.Actor | ||
{ | ||
/// <summary> | ||
/// Tests the default memory footprint of an Akka.NET actor | ||
/// </summary> | ||
public class ActorMemoryFootprintSpec | ||
{ | ||
class MemoryUntypedActor : UntypedActor { | ||
protected override void OnReceive(object message) | ||
{ | ||
if (message is string) return; | ||
if (message is int) return; | ||
if (message is bool) return; | ||
Unhandled(message); | ||
} | ||
} | ||
|
||
class MemoryReceiveActor : ReceiveActor | ||
{ | ||
public MemoryReceiveActor() | ||
{ | ||
Receive<string>(s => { }); | ||
Receive<int>(i => { }); | ||
Receive<bool>(b => { }); | ||
} | ||
} | ||
|
||
private static readonly AtomicCounter Counter = new AtomicCounter(0); | ||
private ActorSystem _system; | ||
private Counter _createActorThroughput; | ||
|
||
private const string CreateThroughputCounter = "ActorCreateThroughput"; | ||
private const int ActorCreateNumber = 10000; | ||
|
||
private static readonly Props UntypedActorProps = Props.Create(() => new MemoryUntypedActor()); | ||
private static readonly Props ReceiveActorProps = Props.Create(() => new MemoryReceiveActor()); | ||
|
||
[PerfSetup] | ||
public void Setup(BenchmarkContext context) | ||
{ | ||
_system = ActorSystem.Create("ActorMemoryFootprintSpec" + Counter.GetAndIncrement()); | ||
_createActorThroughput = context.GetCounter(CreateThroughputCounter); | ||
} | ||
|
||
[PerfBenchmark(Description = "Measures the amount of memory used by 10,000 UntypedActors", RunMode = RunMode.Iterations, NumberOfIterations = 13, TestMode = TestMode.Measurement)] | ||
[MemoryMeasurement(MemoryMetric.TotalBytesAllocated)] | ||
[CounterMeasurement(CreateThroughputCounter)] | ||
public void UntypedActorMemoryFootprint(BenchmarkContext context) | ||
{ | ||
for (var i = 0; i < ActorCreateNumber; i++) | ||
{ | ||
_system.ActorOf(UntypedActorProps); | ||
_createActorThroughput.Increment(); | ||
} | ||
} | ||
|
||
[PerfBenchmark(Description = "Measures the amount of memory used by 10,000 ReceiveActors", RunMode = RunMode.Iterations, NumberOfIterations = 13, TestMode = TestMode.Measurement)] | ||
[MemoryMeasurement(MemoryMetric.TotalBytesAllocated)] | ||
[CounterMeasurement(CreateThroughputCounter)] | ||
public void ReceiveActorMemoryFootprint(BenchmarkContext context) | ||
{ | ||
for (var i = 0; i < ActorCreateNumber; i++) | ||
{ | ||
_system.ActorOf(ReceiveActorProps); | ||
_createActorThroughput.Increment(); | ||
} | ||
} | ||
|
||
[PerfCleanup] | ||
public void Teardown(BenchmarkContext context) | ||
{ | ||
_system.Shutdown(); | ||
_system.AwaitTermination(TimeSpan.FromSeconds(2.0d)); | ||
_system = null; | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/core/Akka.Tests.Performance/Akka.Tests.Performance.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{B17DEDCB-D2AA-472D-82A0-D242B711F488}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Akka.Tests.Performance</RootNamespace> | ||
<AssemblyName>Akka.Tests.Performance</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="NBench, Version=0.1.3.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\NBench.0.1.3\lib\net45\NBench.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Actor\ActorMemoryFootprintSpec.cs" /> | ||
<Compile Include="Dispatch\MailboxMemoryFootprintSpec.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Akka.TestKit\Akka.TestKit.csproj"> | ||
<Project>{0d3cbad0-bbdb-43e5-afc4-ed1d3ecdc224}</Project> | ||
<Name>Akka.TestKit</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\Akka\Akka.csproj"> | ||
<Project>{5deddf90-37f0-48d3-a0b0-a5cbd8a7e377}</Project> | ||
<Name>Akka</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<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. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
12 changes: 12 additions & 0 deletions
12
src/core/Akka.Tests.Performance/Dispatch/ConcurrentQueueMailboxThroughputSpec.cs
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,12 @@ | ||
using Akka.Dispatch; | ||
|
||
namespace Akka.Tests.Performance.Dispatch | ||
{ | ||
public class ConcurrentQueueMailboxThroughputSpec : MailboxThroughputSpecBase | ||
{ | ||
protected override Mailbox CreateMailbox() | ||
{ | ||
return new ConcurrentQueueMailbox(); | ||
} | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
src/core/Akka.Tests.Performance/Dispatch/MailboxMemoryFootprintSpec.cs
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,66 @@ | ||
using System.Collections.Generic; | ||
using Akka.Dispatch; | ||
using NBench; | ||
|
||
namespace Akka.Tests.Performance.Dispatch | ||
{ | ||
public class MailboxMemoryFootprintSpec | ||
{ | ||
private Counter _createMailboxThroughput; | ||
|
||
private const string CreateThroughputCounter = "MailboxCreateThroughput"; | ||
private const int MailboxCreateNumber = 10000; | ||
|
||
private List<Mailbox> _mailboxes; | ||
|
||
[PerfSetup] | ||
public void Setup(BenchmarkContext context) | ||
{ | ||
_createMailboxThroughput = context.GetCounter(CreateThroughputCounter); | ||
_mailboxes = new List<Mailbox>(MailboxCreateNumber); | ||
} | ||
|
||
[PerfBenchmark(Description = "Measures the amount of memory used by 10,000 ConcurrentQueueMailboxes", RunMode = RunMode.Iterations, NumberOfIterations = 13, TestMode = TestMode.Measurement)] | ||
[MemoryMeasurement(MemoryMetric.TotalBytesAllocated)] | ||
[CounterMeasurement(CreateThroughputCounter)] | ||
public void ConcurrentQueueMailbox() | ||
{ | ||
for (var i = 0; i < MailboxCreateNumber; i++) | ||
{ | ||
_mailboxes.Add(new ConcurrentQueueMailbox()); | ||
_createMailboxThroughput.Increment(); | ||
} | ||
} | ||
|
||
[PerfBenchmark(Description = "Measures the amount of memory used by 10,000 UnboundedDequeBasedMailboxes", RunMode = RunMode.Iterations, NumberOfIterations = 13, TestMode = TestMode.Measurement)] | ||
[MemoryMeasurement(MemoryMetric.TotalBytesAllocated)] | ||
[CounterMeasurement(CreateThroughputCounter)] | ||
public void UnboundedDequeBasedMailbox() | ||
{ | ||
for (var i = 0; i < MailboxCreateNumber; i++) | ||
{ | ||
_mailboxes.Add(new UnboundedDequeBasedMailbox()); | ||
_createMailboxThroughput.Increment(); | ||
} | ||
} | ||
|
||
[PerfBenchmark(Description = "Measures the amount of memory used by 10,000 BoundedDequeBasedMailboxes", RunMode = RunMode.Iterations, NumberOfIterations = 13, TestMode = TestMode.Measurement)] | ||
[MemoryMeasurement(MemoryMetric.TotalBytesAllocated)] | ||
[CounterMeasurement(CreateThroughputCounter)] | ||
public void BoundedDequeBasedMailbox() | ||
{ | ||
for (var i = 0; i < MailboxCreateNumber; i++) | ||
{ | ||
_mailboxes.Add(new BoundedDequeBasedMailbox()); | ||
_createMailboxThroughput.Increment(); | ||
} | ||
} | ||
|
||
[PerfCleanup] | ||
public void Teardown() | ||
{ | ||
_mailboxes.Clear(); | ||
_mailboxes = null; | ||
} | ||
} | ||
} |
Oops, something went wrong.