Skip to content

Commit

Permalink
Merge pull request #3475 from Horusiath/benchmark-dot-net
Browse files Browse the repository at this point in the history
Introducing BenchmarkDotNet benchmarks
  • Loading branch information
Aaronontheweb authored May 31, 2018
2 parents 68e1f2a + 6ab0b14 commit 1b1146b
Show file tree
Hide file tree
Showing 19 changed files with 1,050 additions and 19 deletions.
49 changes: 32 additions & 17 deletions src/Akka.sln
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Akka.Cluster.Tests.Performa
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Akka.DistributedData.LightningDB", "contrib\cluster\Akka.DistributedData.LightningDB\Akka.DistributedData.LightningDB.csproj", "{99CCB7CA-E1EE-4497-BF52-2200A0EC5CB1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpawnBenchmark", "benchmark\SpawnBenchmark\SpawnBenchmark.csproj", "{DA4BDE1E-1ACA-482A-9329-952C3E36F97D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RemotePingPong", "benchmark\RemotePingPong\RemotePingPong.csproj", "{5AA81B79-34DD-4DD7-9D40-A5CA389786DF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{D3AF8295-AEB5-4324-AA82-FCC0014AC310}"
Expand All @@ -188,9 +186,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.Cluster.Simple", "e
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.Cluster.Transformation", "examples\Cluster\Roles\Samples.Cluster.Transformation\Samples.Cluster.Transformation.csproj", "{01B074DB-67C8-4600-8CE2-DAAAFC052261}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Akka.FSharp", "core/Akka.FSharp/Akka.FSharp.fsproj", "{483B4579-2665-49FC-A7E4-42C67FEC7531}"
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Akka.FSharp", "core\Akka.FSharp\Akka.FSharp.fsproj", "{483B4579-2665-49FC-A7E4-42C67FEC7531}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Akka.FSharp.Tests", "core\Akka.FSharp.Tests\Akka.FSharp.Tests.fsproj", "{FA2E30CC-9F2D-4BFC-9899-347B32DF7181}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.Benchmarks", "benchmark\Akka.Benchmarks\Akka.Benchmarks.csproj", "{A1D57384-A933-480A-9DF4-FA5E60AB1A67}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Akka.FSharp.Tests", "core/Akka.FSharp.Tests/Akka.FSharp.Tests.fsproj", "{FA2E30CC-9F2D-4BFC-9899-347B32DF7181}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpawnBenchmark", "benchmark\SpawnBenchmark\SpawnBenchmark.csproj", "{9BEAF609-B406-4CCB-9708-6E8DFF764232}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -695,18 +697,6 @@ Global
{99CCB7CA-E1EE-4497-BF52-2200A0EC5CB1}.Release|x64.Build.0 = Release|Any CPU
{99CCB7CA-E1EE-4497-BF52-2200A0EC5CB1}.Release|x86.ActiveCfg = Release|Any CPU
{99CCB7CA-E1EE-4497-BF52-2200A0EC5CB1}.Release|x86.Build.0 = Release|Any CPU
{DA4BDE1E-1ACA-482A-9329-952C3E36F97D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA4BDE1E-1ACA-482A-9329-952C3E36F97D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA4BDE1E-1ACA-482A-9329-952C3E36F97D}.Debug|x64.ActiveCfg = Debug|Any CPU
{DA4BDE1E-1ACA-482A-9329-952C3E36F97D}.Debug|x64.Build.0 = Debug|Any CPU
{DA4BDE1E-1ACA-482A-9329-952C3E36F97D}.Debug|x86.ActiveCfg = Debug|Any CPU
{DA4BDE1E-1ACA-482A-9329-952C3E36F97D}.Debug|x86.Build.0 = Debug|Any CPU
{DA4BDE1E-1ACA-482A-9329-952C3E36F97D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA4BDE1E-1ACA-482A-9329-952C3E36F97D}.Release|Any CPU.Build.0 = Release|Any CPU
{DA4BDE1E-1ACA-482A-9329-952C3E36F97D}.Release|x64.ActiveCfg = Release|Any CPU
{DA4BDE1E-1ACA-482A-9329-952C3E36F97D}.Release|x64.Build.0 = Release|Any CPU
{DA4BDE1E-1ACA-482A-9329-952C3E36F97D}.Release|x86.ActiveCfg = Release|Any CPU
{DA4BDE1E-1ACA-482A-9329-952C3E36F97D}.Release|x86.Build.0 = Release|Any CPU
{5AA81B79-34DD-4DD7-9D40-A5CA389786DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5AA81B79-34DD-4DD7-9D40-A5CA389786DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5AA81B79-34DD-4DD7-9D40-A5CA389786DF}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -815,6 +805,30 @@ Global
{FA2E30CC-9F2D-4BFC-9899-347B32DF7181}.Release|x64.Build.0 = Release|Any CPU
{FA2E30CC-9F2D-4BFC-9899-347B32DF7181}.Release|x86.ActiveCfg = Release|Any CPU
{FA2E30CC-9F2D-4BFC-9899-347B32DF7181}.Release|x86.Build.0 = Release|Any CPU
{A1D57384-A933-480A-9DF4-FA5E60AB1A67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A1D57384-A933-480A-9DF4-FA5E60AB1A67}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1D57384-A933-480A-9DF4-FA5E60AB1A67}.Debug|x64.ActiveCfg = Debug|Any CPU
{A1D57384-A933-480A-9DF4-FA5E60AB1A67}.Debug|x64.Build.0 = Debug|Any CPU
{A1D57384-A933-480A-9DF4-FA5E60AB1A67}.Debug|x86.ActiveCfg = Debug|Any CPU
{A1D57384-A933-480A-9DF4-FA5E60AB1A67}.Debug|x86.Build.0 = Debug|Any CPU
{A1D57384-A933-480A-9DF4-FA5E60AB1A67}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1D57384-A933-480A-9DF4-FA5E60AB1A67}.Release|Any CPU.Build.0 = Release|Any CPU
{A1D57384-A933-480A-9DF4-FA5E60AB1A67}.Release|x64.ActiveCfg = Release|Any CPU
{A1D57384-A933-480A-9DF4-FA5E60AB1A67}.Release|x64.Build.0 = Release|Any CPU
{A1D57384-A933-480A-9DF4-FA5E60AB1A67}.Release|x86.ActiveCfg = Release|Any CPU
{A1D57384-A933-480A-9DF4-FA5E60AB1A67}.Release|x86.Build.0 = Release|Any CPU
{9BEAF609-B406-4CCB-9708-6E8DFF764232}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9BEAF609-B406-4CCB-9708-6E8DFF764232}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9BEAF609-B406-4CCB-9708-6E8DFF764232}.Debug|x64.ActiveCfg = Debug|Any CPU
{9BEAF609-B406-4CCB-9708-6E8DFF764232}.Debug|x64.Build.0 = Debug|Any CPU
{9BEAF609-B406-4CCB-9708-6E8DFF764232}.Debug|x86.ActiveCfg = Debug|Any CPU
{9BEAF609-B406-4CCB-9708-6E8DFF764232}.Debug|x86.Build.0 = Debug|Any CPU
{9BEAF609-B406-4CCB-9708-6E8DFF764232}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9BEAF609-B406-4CCB-9708-6E8DFF764232}.Release|Any CPU.Build.0 = Release|Any CPU
{9BEAF609-B406-4CCB-9708-6E8DFF764232}.Release|x64.ActiveCfg = Release|Any CPU
{9BEAF609-B406-4CCB-9708-6E8DFF764232}.Release|x64.Build.0 = Release|Any CPU
{9BEAF609-B406-4CCB-9708-6E8DFF764232}.Release|x86.ActiveCfg = Release|Any CPU
{9BEAF609-B406-4CCB-9708-6E8DFF764232}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -885,7 +899,6 @@ Global
{E7A836C1-42D3-4ADC-81C6-C6C5398CC740} = {7625FD95-4B2C-4A5B-BDD5-94B1493FAC8E}
{94C10096-C33E-404E-B0FB-F8535512A952} = {01167D3C-49C4-4CDE-9787-C176D139ACDD}
{99CCB7CA-E1EE-4497-BF52-2200A0EC5CB1} = {76F58DC4-19F1-43EF-A6E2-EC1CC8395AC5}
{DA4BDE1E-1ACA-482A-9329-952C3E36F97D} = {73108242-625A-4D7B-AA09-63375DBAE464}
{5AA81B79-34DD-4DD7-9D40-A5CA389786DF} = {73108242-625A-4D7B-AA09-63375DBAE464}
{C50E1A9E-820C-4E75-AE39-6F96A99AC4A7} = {D3AF8295-AEB5-4324-AA82-FCC0014AC310}
{820CFBF7-E165-4ADA-B821-E6A0A81DFE84} = {C50E1A9E-820C-4E75-AE39-6F96A99AC4A7}
Expand All @@ -898,6 +911,8 @@ Global
{01B074DB-67C8-4600-8CE2-DAAAFC052261} = {C50E1A9E-820C-4E75-AE39-6F96A99AC4A7}
{483B4579-2665-49FC-A7E4-42C67FEC7531} = {01167D3C-49C4-4CDE-9787-C176D139ACDD}
{FA2E30CC-9F2D-4BFC-9899-347B32DF7181} = {01167D3C-49C4-4CDE-9787-C176D139ACDD}
{A1D57384-A933-480A-9DF4-FA5E60AB1A67} = {73108242-625A-4D7B-AA09-63375DBAE464}
{9BEAF609-B406-4CCB-9708-6E8DFF764232} = {73108242-625A-4D7B-AA09-63375DBAE464}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {03AD8E21-7507-4E68-A4E9-F4A7E7273164}
Expand Down
51 changes: 51 additions & 0 deletions src/benchmark/Akka.Benchmarks/Actor/ActorPathBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//-----------------------------------------------------------------------
// <copyright file="ActorPathBenchmarks.cs" company="Akka.NET Project">
// Copyright (C) 2009-2018 Lightbend Inc. <http://www.lightbend.com>
// Copyright (C) 2013-2018 .NET Foundation <https://github.com/akkadotnet/akka.net>
// </copyright>
//-----------------------------------------------------------------------

using Akka.Actor;
using Akka.Benchmarks.Configurations;
using BenchmarkDotNet.Attributes;

namespace Akka.Benchmarks.Actor
{
[Config(typeof(MicroBenchmarkConfig))]
public class ActorPathBenchmarks
{
private ActorPath x;
private ActorPath y;

[GlobalSetup]
public void Setup()
{
x = new RootActorPath(new Address("akka.tcp", "system", "127.0.0.1", 1337), "user");
y = new RootActorPath(new Address("akka.tcp", "system", "127.0.0.1", 1337), "system");
}

[Benchmark]
public ActorPath ActorPath_Parse()
{
return ActorPath.Parse("akka.tcp://system/user/parent/child");
}

[Benchmark]
public ActorPath ActorPath_Concat()
{
return x / "parent" / "child";
}

[Benchmark]
public bool ActorPath_Equals()
{
return x == y;
}

[Benchmark]
public string ActorPath_ToString()
{
return x.ToString();
}
}
}
57 changes: 57 additions & 0 deletions src/benchmark/Akka.Benchmarks/Actor/AddressBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//-----------------------------------------------------------------------
// <copyright file="AddressBenchmarks.cs" company="Akka.NET Project">
// Copyright (C) 2009-2018 Lightbend Inc. <http://www.lightbend.com>
// Copyright (C) 2013-2018 .NET Foundation <https://github.com/akkadotnet/akka.net>
// </copyright>
//-----------------------------------------------------------------------

using Akka.Actor;
using Akka.Benchmarks.Configurations;
using BenchmarkDotNet.Attributes;

namespace Akka.Benchmarks.Actor
{
[Config(typeof(MicroBenchmarkConfig))]
public class AddressBenchmarks
{
private Address x;
private Address y;

[GlobalSetup]
public void Setup()
{
x = new Address("akka.tcp", "test-system", "10.62.0.101", 4000);
y = new Address("akka.tcp", "test-system", "10.62.0.101", 4123);
}

[Benchmark]
public Address Address_Parse()
{
return Address.Parse("akka.tcp://test-system@10.62.0.100:5000/");
}

[Benchmark]
public int Address_CompareTo()
{
return x.CompareTo(y);
}

[Benchmark]
public string Address_ToString()
{
return x.ToString();
}

[Benchmark]
public bool Address_Equals()
{
return x == y;
}

[Benchmark]
public int Address_GetHashCode()
{
return x.GetHashCode();
}
}
}
114 changes: 114 additions & 0 deletions src/benchmark/Akka.Benchmarks/Actor/PingPongBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// //-----------------------------------------------------------------------
// <copyright file="PingPongBenchmarks.cs" company="Akka.NET Project">
// Copyright (C) 2009-2018 Lightbend Inc. <http://www.lightbend.com>
// Copyright (C) 2013-2018 .NET Foundation <https://github.com/akkadotnet/akka.net>
// </copyright>
//-----------------------------------------------------------------------

using System;
using System.Threading.Tasks;
using Akka.Actor;
using Akka.Benchmarks.Configurations;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Attributes.Jobs;
using BenchmarkDotNet.Engines;

namespace Akka.Benchmarks.Actor
{
[Config(typeof(MonitoringConfig))]
[SimpleJob(RunStrategy.Monitoring, launchCount: 3, warmupCount: 3, targetCount: 3)]
public class PingPongBenchmarks
{
public const int Operations = 1_000_000;
private TimeSpan timeout;
private ActorSystem system;
private IActorRef ping;

[GlobalSetup]
public void Setup()
{
timeout = TimeSpan.FromMinutes(1);
system = ActorSystem.Create("system");
var pong = system.ActorOf(Props.Create(() => new Pong()));
ping = system.ActorOf(Props.Create(() => new Ping(pong)));
}

[GlobalCleanup]
public void Cleanup()
{
system.Dispose();
}

[Benchmark(OperationsPerInvoke = Operations)]
public async Task Actor_ping_pong_single_pair_in_memory()
{
await ping.Ask(StartTest.Instance, timeout);
}

#region actors

sealed class StartTest
{
public static readonly StartTest Instance = new StartTest();
private StartTest() { }
}

sealed class Signal
{
public int Remaining { get; }

public Signal(int remaining)
{
Remaining = remaining;
}
}

sealed class TestDone
{
public static readonly TestDone Instance = new TestDone();
private TestDone() { }
}

sealed class Ping : ReceiveActor
{
private IActorRef replyTo;

public Ping(IActorRef pong)
{
Receive<StartTest>(_ =>
{
replyTo = Sender;

var signal = new Signal(Operations);
pong.Tell(signal);
});

Receive<Signal>(signal =>
{
var remaining = signal.Remaining;
if (remaining <= 0)
{
replyTo.Tell(TestDone.Instance);
}
else
{
Sender.Tell(new Signal(remaining - 1));
}
});
}
}
sealed class Pong : ReceiveActor
{
public Pong()
{
Receive<Signal>(signal =>
{
Sender.Tell(new Signal(signal.Remaining - 1));
});
}
}

#endregion

}
}
Loading

0 comments on commit 1b1146b

Please sign in to comment.