Пример #1
0
        static void RunRequestResponseBenchmark(ProgramOptionSet optionSet)
        {
            var requestResponseOptionSet = new RequestResponseOptionSet();

            requestResponseOptionSet.Parse(_remaining);

            IRequestResponseSettings settings = requestResponseOptionSet;

            IRequestResponseTransport transport;

            if (optionSet.Transport == ProgramOptionSet.TransportOptions.AzureServiceBus)
            {
                var serviceBusOptionSet = new ServiceBusOptionSet();

                serviceBusOptionSet.Parse(_remaining);

                serviceBusOptionSet.ShowOptions();

                ServicePointManager.Expect100Continue = false;
                ServicePointManager.UseNagleAlgorithm = false;

                transport = new ServiceBusRequestResponseTransport(serviceBusOptionSet, settings);
            }
            else if (optionSet.Transport == ProgramOptionSet.TransportOptions.RabbitMq)
            {
                var rabbitMqOptionSet = new RabbitMqOptionSet();
                rabbitMqOptionSet.Parse(_remaining);

                rabbitMqOptionSet.ShowOptions();

                transport = new RabbitMqRequestResponseTransport(rabbitMqOptionSet, settings);
            }
            else if (optionSet.Transport == ProgramOptionSet.TransportOptions.Mediator)
            {
                transport = new MediatorRequestResponseTransport(settings);
            }
            else
            {
                var inMemoryOptionSet = new InMemoryOptionSet();
                inMemoryOptionSet.Parse(_remaining);

                inMemoryOptionSet.ShowOptions();

                transport = new InMemoryRequestResponseTransport(inMemoryOptionSet, settings);
            }

            var benchmark = new RequestResponseBenchmark(transport, settings);

            benchmark.Run();
        }
Пример #2
0
        static async Task RunLatencyBenchmark(ProgramOptionSet optionSet)
        {
            var messageLatencyOptionSet = new MessageLatencyOptionSet();

            messageLatencyOptionSet.Parse(_remaining);

            IMessageLatencySettings settings = messageLatencyOptionSet;

            IMessageLatencyTransport transport;

            if (optionSet.Transport == ProgramOptionSet.TransportOptions.AzureServiceBus)
            {
                var serviceBusOptionSet = new ServiceBusOptionSet();

                serviceBusOptionSet.Parse(_remaining);

                serviceBusOptionSet.ShowOptions();

                ServicePointManager.Expect100Continue = false;
                ServicePointManager.UseNagleAlgorithm = false;

                transport = new ServiceBusMessageLatencyTransport(serviceBusOptionSet, settings);
            }
            else if (optionSet.Transport == ProgramOptionSet.TransportOptions.RabbitMq)
            {
                var rabbitMqOptionSet = new RabbitMqOptionSet();
                rabbitMqOptionSet.Parse(_remaining);

                rabbitMqOptionSet.ShowOptions();

                transport = new RabbitMqMessageLatencyTransport(rabbitMqOptionSet, settings);
            }
            else if (optionSet.Transport == ProgramOptionSet.TransportOptions.AmazonSqs)
            {
                var amazonSqsOptionSet = new AmazonSqsOptionSet();
                amazonSqsOptionSet.Parse(_remaining);

                amazonSqsOptionSet.ShowOptions();

                transport = new AmazonSqsMessageLatencyTransport(amazonSqsOptionSet, settings);
            }
            else if (optionSet.Transport == ProgramOptionSet.TransportOptions.ActiveMq)
            {
                var activeMqOptionSet = new ActiveMqOptionSet();
                activeMqOptionSet.Parse(_remaining);

                activeMqOptionSet.ShowOptions();

                transport = new ActiveMqMessageLatencyTransport(activeMqOptionSet, settings);
            }
            else if (optionSet.Transport == ProgramOptionSet.TransportOptions.Grpc)
            {
                var grpcOptionSet = new GrpcOptionSet();
                grpcOptionSet.Parse(_remaining);

                grpcOptionSet.ShowOptions();

                transport = new GrpcMessageLatencyTransport(grpcOptionSet, settings);
            }
            else if (optionSet.Transport == ProgramOptionSet.TransportOptions.Mediator)
            {
                transport = new MediatorMessageLatencyTransport(settings);
            }
            else
            {
                var inMemoryOptionSet = new InMemoryOptionSet();
                inMemoryOptionSet.Parse(_remaining);

                inMemoryOptionSet.ShowOptions();

                transport = new InMemoryMessageLatencyTransport(inMemoryOptionSet, settings);
            }

            var benchmark = new MessageLatencyBenchmark(transport, settings);

            await benchmark.Run();
        }