示例#1
0
        public static void Main(string[] args)
        {
            if (args.Length != 3 && args.Length != 4)
            {
                Console.WriteLine($"Usage: .. [runProduce 1=true;0=false] <broker,broker..> <topic> [header-count]");
                return;
            }

            bool runProduce = false;

            if (Int32.TryParse(args[0], out Int32 firstParmValue) == true)
            {
                runProduce = (firstParmValue == 1);
            }
            var bootstrapServers = args[1];
            var topic            = args[2];
            var headerCount      = 0;

            if (args.Length > 3)
            {
                headerCount = int.Parse(args[3]);
            }

            const int NUMBER_OF_MESSAGES = 500000;
            const int NUMBER_OF_TESTS    = 1;
            long      firstMessageOffset = 1;

            if (runProduce == true)
            {
                BenchmarkProducer.TaskProduce(bootstrapServers, topic, NUMBER_OF_MESSAGES, headerCount, NUMBER_OF_TESTS);
                firstMessageOffset = BenchmarkProducer.DeliveryHandlerProduce(bootstrapServers, topic, NUMBER_OF_MESSAGES, headerCount, NUMBER_OF_TESTS);
            }

            BenchmarkConsumer.Consume(bootstrapServers, topic, firstMessageOffset, NUMBER_OF_MESSAGES, headerCount, NUMBER_OF_TESTS);
        }
示例#2
0
        public static void Main(string[] args)
        {
            if (args.Length != 2 && args.Length != 3)
            {
                Console.WriteLine($"Usage: .. <broker,broker..> <topic> [use-partitioner] [header-count]");
                return;
            }

            var bootstrapServers = args[0];
            var topic            = args[1];
            var usePartitioner   = args.Any(arg => arg.Contains("use-partitioner"));

            var headerCount = 0;

            if (args.Length > 2)
            {
                if (int.TryParse(args[2], out headerCount) || int.TryParse(args[3], out headerCount))
                {
                    Console.WriteLine($"Parsed header count as {headerCount}");
                }
            }

            const int NUMBER_OF_MESSAGES = 5_000_000;
            const int NUMBER_OF_TESTS    = 1;

            BenchmarkProducer.TaskProduce(bootstrapServers, topic, NUMBER_OF_MESSAGES, headerCount, NUMBER_OF_TESTS, usePartitioner);
            var firstMessageOffset = BenchmarkProducer.DeliveryHandlerProduce(bootstrapServers, topic, NUMBER_OF_MESSAGES, headerCount, NUMBER_OF_TESTS, usePartitioner);

            BenchmarkConsumer.Consume(bootstrapServers, topic, firstMessageOffset, NUMBER_OF_MESSAGES, headerCount, NUMBER_OF_TESTS);
        }
示例#3
0
        public static void Main(string[] args)
        {
            if (args.Length != 2 && args.Length != 3)
            {
                Console.WriteLine($"Usage: .. <broker,broker..> <topic> [header-count]");
                return;
            }

            var bootstrapServers = args[0];
            var topic            = args[1];
            var headerCount      = 0;

            if (args.Length > 2)
            {
                headerCount = int.Parse(args[2]);
            }

            const int NUMBER_OF_MESSAGES = 5000000;
            const int NUMBER_OF_TESTS    = 1;

            BenchmarkProducer.TaskProduce(bootstrapServers, topic, NUMBER_OF_MESSAGES, headerCount, NUMBER_OF_TESTS);
            var firstMessageOffset = BenchmarkProducer.DeliveryHandlerProduce(bootstrapServers, topic, NUMBER_OF_MESSAGES, headerCount, NUMBER_OF_TESTS);

            BenchmarkConsumer.Consume(bootstrapServers, topic, firstMessageOffset, NUMBER_OF_MESSAGES, headerCount, NUMBER_OF_TESTS);
        }
示例#4
0
        public static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine($"Usage: dotnet run <broker,broker..> <topic>");
                return;
            }

            var bootstrapServers = args[0];
            var topic            = args[1];

            const int NUMBER_OF_MESSAGES = 5000000;
            const int NUMBER_OF_TESTS    = 1;

            BenchmarkProducer.TaskProduce(bootstrapServers, topic, NUMBER_OF_MESSAGES, NUMBER_OF_TESTS);
            var firstMessageOffset = BenchmarkProducer.DeliveryHandlerProduce(bootstrapServers, topic, NUMBER_OF_MESSAGES, NUMBER_OF_TESTS);

            BenchmarkConsumer.Poll(bootstrapServers, topic, firstMessageOffset, NUMBER_OF_MESSAGES, NUMBER_OF_TESTS);
            BenchmarkConsumer.Consume(bootstrapServers, topic, firstMessageOffset, NUMBER_OF_MESSAGES, NUMBER_OF_TESTS);
        }
示例#5
0
        public static void Main(string[] args)
        {
            bool   showHelp          = false;
            string mode              = null;
            string bootstrapServers  = "localhost:9092";
            string topicName         = "dotnet-benchmark";
            string group             = "benchmark-consumer-group";
            int    headerCount       = 0;
            int?   messagesPerSecond = null;
            int    numberOfMessages  = 5000000;
            int    messageSize       = 100;
            int?   partitionCount    = null;
            short  replicationFactor = 3;
            string username          = null;
            string password          = null;

            OptionSet p = new OptionSet
            {
                { "m|mode=", "throughput|latency", m => mode = m },
                { "b|brokers=", $"bootstrap.servers (default: {bootstrapServers})", v => bootstrapServers = v },
                { "t=", $"topic (default: {topicName})", t => topicName = t },
                { "g=", $"consumer group (default: {group})", g => group = g },
                { "h=", $"number of headers (default: {headerCount})", h => headerCount = int.Parse(h) },
                { "n=", $"number of messages (default: {numberOfMessages})", n => numberOfMessages = int.Parse(n) },
                { "r=", "rate - messages per second (latency mode only). must be > 1000", (int r) => messagesPerSecond = r },
                { "s=", $"message size (default: {messageSize})", s => messageSize = int.Parse(s) },
                { "p=", "(re)create topic with this partition count (default: not set)", v => partitionCount = int.Parse(v) },
                { "f=", $"replication factor when creating topic (default {replicationFactor})", f => replicationFactor = short.Parse(f) },
                { "u=", "SASL username (will also set protocol=SASL_SSL, mechanism=PLAIN)", u => username = u },
                { "w=", "SASL password", w => password = w },
                { "help", "show this message and exit", v => showHelp = v != null },
            };

            p.Parse(args);

            if (mode == null || showHelp ||
                (messagesPerSecond != null && mode == "throughput") ||
                (messagesPerSecond == null && mode == "latency"))
            {
                Console.WriteLine("Usage:");
                p.WriteOptionDescriptions(Console.Out);
                return;
            }

            if (partitionCount != null)
            {
                CreateTopic(bootstrapServers, username, password, topicName, partitionCount.Value, replicationFactor);
            }

            if (mode == "throughput")
            {
                const int NUMBER_OF_TESTS = 1;
                BenchmarkProducer.TaskProduce(bootstrapServers, topicName, numberOfMessages, headerCount, messageSize, NUMBER_OF_TESTS, username, password);
                var firstMessageOffset = BenchmarkProducer.DeliveryHandlerProduce(bootstrapServers, topicName, numberOfMessages, messageSize, headerCount, NUMBER_OF_TESTS, username, password);
                BenchmarkConsumer.Consume(bootstrapServers, topicName, group, firstMessageOffset, numberOfMessages, headerCount, NUMBER_OF_TESTS, username, password);
            }
            else if (mode == "latency")
            {
                Latency.Run(bootstrapServers, topicName, group, headerCount, messageSize, messagesPerSecond.Value, numberOfMessages, username, password);
            }
        }