Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added actor messaging pressure benchmark #6147

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// //-----------------------------------------------------------------------
// // <copyright file="ActorMessagingMemoryPressureBenchmark.cs" company="Akka.NET Project">
// // Copyright (C) 2009-2022 Lightbend Inc. <http://www.lightbend.com>
// // Copyright (C) 2013-2022 .NET Foundation <https://github.com/akkadotnet/akka.net>
// // </copyright>
// //-----------------------------------------------------------------------

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

namespace Akka.Benchmarks.Actor
{
[Config(typeof(MicroBenchmarkConfig))]
public class ActorMessagingMemoryPressureBenchmark
{
#region Classes
public sealed class StopActor
{
private StopActor(){}
public static readonly StopActor Instance = new StopActor();
}

public sealed class MyActor : ReceiveActor
{
public MyActor()
{
Receive<StopActor>(str =>
{
Context.Stop(Self);
Sender.Tell(str);
});

Receive<string>(str =>
{
Sender.Tell(str);
});
}
}
#endregion

private ActorSystem _sys;
private IActorRef _actorEntryPoint;

private const string Msg = "hit";

[Params(100_000)]
public int MsgCount { get; set; }

[Params(10, 100)]
public int ActorCount { get; set; }

[GlobalSetup]
public void Setup()
{
_sys = ActorSystem.Create("Bench", @"akka.log-dead-letters = off");
}

[GlobalCleanup]
public async Task CleanUp()
{
await _sys.Terminate();
}

[IterationCleanup]
public void PerInvokeCleanup()
{
_actorEntryPoint.GracefulStop(TimeSpan.FromSeconds(5)).Wait();
}

[IterationSetup]
public void PerInvokeSetup()
{
_actorEntryPoint = _sys.ActorOf(Props.Create<MyActor>().WithRouter(new BroadcastPool(ActorCount)));
}

[Benchmark]
public Task PushMsgs()
{
for (var i = 0; i < MsgCount; i++)
{
_actorEntryPoint.Tell(Msg);
}

return Task.CompletedTask;
}
}
}
4 changes: 2 additions & 2 deletions src/benchmark/Akka.Benchmarks/Actor/FsmBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ public void Setup()
}

[GlobalCleanup]
public void CleanUp()
public async Task CleanUp()
{
_sys.Terminate().Wait();
await _sys.Terminate();
}

[Benchmark]
Expand Down