Akka.Remote.Tests.Performance.Transports.RemoteMessagingThroughputSpecBase.Setup C# (CSharp) Method

Setup() private method

private Setup ( BenchmarkContext context ) : void
context NBench.BenchmarkContext
return void
        public void Setup(BenchmarkContext context)
        {
            _remoteMessageThroughput = context.GetCounter(RemoteMessageCounterName);
            System1 = ActorSystem.Create("SystemA" + ActorSystemNameCounter.Next(), CreateActorSystemConfig("SystemA" + ActorSystemNameCounter.Current, "127.0.0.1", 0));
            _echo = System1.ActorOf(Props.Create(() => new EchoActor()), "echo");

            System2 = ActorSystem.Create("SystemB" + ActorSystemNameCounter.Next(), CreateActorSystemConfig("SystemB" + ActorSystemNameCounter.Current, "127.0.0.1", 0));
            _receiver =
                System2.ActorOf(
                    Props.Create(() => new BenchmarkActor(_remoteMessageThroughput, RemoteMessageCount, _resetEvent)),
                    "benchmark");

            var system1Address = RARP.For(System1).Provider.Transport.DefaultAddress;
            var system2Address = RARP.For(System2).Provider.Transport.DefaultAddress;

            var system1EchoActorPath = new RootActorPath(system1Address) / "user" / "echo";
            var system2RemoteActorPath = new RootActorPath(system2Address) / "user" / "benchmark";

            try
            {
                // set the timeout high here to avoid timeouts
                // TL;DR; - on slow machines it can take longer than 2 seconds to form the association, do the handshake, and reply back
                // using the in-memory transport.
                _remoteReceiver =
                    System1.ActorSelection(system2RemoteActorPath).ResolveOne(TimeSpan.FromSeconds(30)).Result;
                _remoteEcho =
                    System2.ActorSelection(system1EchoActorPath).ResolveOne(TimeSpan.FromSeconds(2)).Result;
            }
            catch (Exception ex)
            {
                context.Trace.Error(ex, "error occurred during setup.");
                throw; // re-throw the error to blow up the benchmark
            }
        }