Skip to content

Commit

Permalink
[Benchmarks] Add Ask vs. Tell memory pressure baseline (#7244)
Browse files Browse the repository at this point in the history
* added baseline for measuring Ask vs. Tell memory pressure

* remove unnecessary cleanup

* made it easier to understand requests / second
  • Loading branch information
Aaronontheweb committed Jun 10, 2024
1 parent b5a133a commit 3bd219e
Showing 1 changed file with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Akka.Benchmarks.Actor
{
[Config(typeof(MicroBenchmarkConfig))]
[Config(typeof(MonitoringConfig))]
public class ActorMessagingMemoryPressureBenchmark
{
#region Classes
Expand Down Expand Up @@ -46,12 +46,13 @@ public MyActor()
private IActorRef _actorEntryPoint;

private const string Msg = "hit";

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

public const int MsgCount = 100_000;

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

private Task[] _askTasks;

[GlobalSetup]
public void Setup()
Expand All @@ -75,9 +76,10 @@ public void PerInvokeCleanup()
public void PerInvokeSetup()
{
_actorEntryPoint = _sys.ActorOf(Props.Create<MyActor>().WithRouter(new BroadcastPool(ActorCount)));
_askTasks = new Task[MsgCount];
}

[Benchmark]
[Benchmark(Baseline = true, OperationsPerInvoke = MsgCount)]
public Task PushMsgs()
{
for (var i = 0; i < MsgCount; i++)
Expand All @@ -87,5 +89,16 @@ public Task PushMsgs()

return Task.CompletedTask;
}

[Benchmark(OperationsPerInvoke = MsgCount)]
public Task AskMsgs()
{
for (var i = 0; i < MsgCount; i++)
{
_askTasks[i] = _actorEntryPoint.Ask<string>(Msg);
}

return Task.WhenAll(_askTasks);
}
}
}

0 comments on commit 3bd219e

Please sign in to comment.