Abc.Zebus.Tests.Transport.ZmqTransportPerformanceTests.CreateAndStartZmqTransport(string, System.Action)

Here are the examples of the csharp api class Abc.Zebus.Tests.Transport.ZmqTransportPerformanceTests.CreateAndStartZmqTransport(string, System.Action) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

1. Example

View license
[Test]
        public void CreateIdleTransport()
        {
            var transport = CreateAndStartZmqTransport("Abc.Testing.Sender");

            Thread.Sleep(30000);

            transport.Stop();
        }

2. Example

View license
[Test]
        public void MeasureThroughput()
        {
            const int sendMessageCount = 2000000;

            var senderTransport = CreateAndStartZmqTransport("Abc.Testing.Sender");

            var receivedMessageCount = 0;
            var receiverTransport = CreateAndStartZmqTransport("Abc.Testing.Receiver", _ => ++receivedMessageCount);
            var receivers = new[] { new Peer(receiverTransport.PeerId, receiverTransport.InboundEndPoint) };

            var transportMessage = new FakeCommand(42).ToTransportMessage();
            senderTransport.Send(transportMessage, receivers);

            var spinWait = new SpinWait();
            while (receivedMessageCount != 1)
                spinWait.SpinOnce();

            using (Measure.Throughput(sendMessageCount))
            {
                for (var i = 0; i < sendMessageCount; ++i)
                {
                    senderTransport.Send(transportMessage, receivers);
                }

                while (receivedMessageCount != sendMessageCount + 1)
                    spinWait.SpinOnce();
            }

            senderTransport.Stop();
            receiverTransport.Stop();
        }