我们看到 Akka.net actor 每个大约 2900 字节。(Akka.net v0.6.1.0)
这是 Akka.net 中每个演员的大致尺寸吗?
程序片段
ActorSystem actor_system = ActorSystem.Create("myActor");//create an actor
var greeter = actor_system.ActorOf<GreetingActor>("greeter");
InternalActorRef[] greeterArray = new InternalActorRef[100000];
for (int i = 0; i < greeterArray.Length; i++)
{
greeterArray[i] = actor_system.ActorOf<GreetingActor>("greeter" + i);
Console.WriteLine("Creating Actor number " + i);
}
招待员
using Akka;
using Akka.Remote;
using Akka.slf4net;
using Akka.Actor;
namespace Akka_NET_test
{
//Create the actor class
public class GreetingActor : UntypedActor
{
protected override void OnReceive(object message)
{
message
.Match()
//this can be done with "if (message is Greet)" if you prefer
.With<Greet>(m => Console.WriteLine("Hello {0} from GreetingActor " + this.Self.ToString(), m.myMsg));
}
}
}
迎接
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Akka;
using Akka.Remote;
using Akka.slf4net;
namespace Akka_NET_test
{
//Create a message type that your actor will respond to
public class Greet
{
public string myMsg { get; set; }
}
}
据报告,Akka jvm 的大小约为 400 字节/actor,Erlang 的大小约为 300 字节/进程。
在 Akka.net 中的 CLR 上旋转 100,000 个演员似乎每个大约 2900 字节。
这大致正确吗?
提前致谢!