Actor模型中消息传递的表现

发布于 2024-09-11 20:31:15 字数 1539 浏览 11 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清泪尽 2024-09-18 20:31:15

中实现的基准测试

  • 这里是在Akka 0.8.1 (Scala)
  • Scala Actors
  • Jetlang (Java)

另请参阅 Azul Vega 1 + Scala actor用于有趣语言的 Azul 快速字节码本文

Here is a benchmark implemented in

  • Akka 0.8.1 (Scala)
  • Scala Actors
  • Jetlang (Java)

Also see Azul Vega 1 + Scala actors and Azul Fast Bytecodes for Funny Languages and this paper.

微暖i 2024-09-18 20:31:15

当我使用这个围绕我的模型实现构建的简单参与者进行性能测试时,它每秒的吞吐量为 444773.906 条消息。显然,这是一个人为的测试,但它可以让您大致了解它在野外的表现。

private class TestActor : Actor<int, bool>
{
    protected override void ProcessMessage(AsyncReplyPackage<int, bool> package)
    {
        package.ReplyChannel.Send(package.Message > 2000000);
    }
}

static void Main(string[] args)
{
    var r = false;
    using (var ts = new TestActor())
    using (var rc = new AsyncChannel<bool>())
    {
        ts.PostWithAsyncReply(0, rc);
        r = rc.Receive();

        var count = 3000000;
        var sw = Stopwatch.StartNew();
        for (int i = 0; i < count; i++)
        {
            ts.PostWithAsyncReply(i, rc);
            r = rc.Receive();
        }
        Console.WriteLine(sw.Elapsed);
    }
    Console.WriteLine(r);
    Console.ReadLine();           
}

大小

我打开了探查器,看起来我的实现是 944 字节。 :(

When I ran a performance test with this simple actor built around my implementation of the model it had a 444773.906 message per second throughput. Clearly it is a contrived test but it gives you a general idea of how it might perform in the wild.

private class TestActor : Actor<int, bool>
{
    protected override void ProcessMessage(AsyncReplyPackage<int, bool> package)
    {
        package.ReplyChannel.Send(package.Message > 2000000);
    }
}

static void Main(string[] args)
{
    var r = false;
    using (var ts = new TestActor())
    using (var rc = new AsyncChannel<bool>())
    {
        ts.PostWithAsyncReply(0, rc);
        r = rc.Receive();

        var count = 3000000;
        var sw = Stopwatch.StartNew();
        for (int i = 0; i < count; i++)
        {
            ts.PostWithAsyncReply(i, rc);
            r = rc.Receive();
        }
        Console.WriteLine(sw.Elapsed);
    }
    Console.WriteLine(r);
    Console.ReadLine();           
}

Size

I broke out the profiler and it looks like my implementation is 944 bytes. :(

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文