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 real UID to ActorPathBenchmarks #6276

Merged
merged 2 commits into from
Nov 29, 2022
Merged
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
12 changes: 10 additions & 2 deletions src/benchmark/Akka.Benchmarks/Actor/ActorPathBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// </copyright>
//-----------------------------------------------------------------------

using System;
using Akka.Actor;
using Akka.Benchmarks.Configurations;
using BenchmarkDotNet.Attributes;
Expand All @@ -20,18 +21,25 @@ public class ActorPathBenchmarks
private Address _sysAdr = new Address("akka.tcp", "system", "127.0.0.1", 1337);
private Address _otherAdr = new Address("akka.tcp", "system", "127.0.0.1", 1338);

private string _actorPathStr;

[Params(1, 100000, int.MaxValue)]
public int Uid { get; set; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameterize the UID using increasing lengths - int.MaxValue is the upper limit of what the UID function will produce in v1.4:

private static long NewUid()
{
// Note that this uid is also used as hashCode in ActorRef, so be careful
// to not break hashing if you change the way uid is generated
var uid = ThreadLocalRandom.Current.Next();
while (uid == UndefinedUid)
uid = ThreadLocalRandom.Current.Next();
return uid;
}


[GlobalSetup]
public void Setup()
{
x = new RootActorPath(_sysAdr, "user");
y = new RootActorPath(_sysAdr, "system");
_childPath = x / "parent" / "child";
var parentPath = x / "parent";
_childPath = new ChildActorPath(parentPath, "child", Uid);
_actorPathStr = _childPath.ToSerializationFormat();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have the string we parse be produced by the absolute path of the ChildActorPath we use for the other tests, including the UID.

}

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

[Benchmark]
Expand Down