static void Main(string[] args)
        {
            var cmd = CommandLineParameters.Parse(args);

            if (cmd == null || cmd.Benchmark != BenchmarkType.None)
            {
                BenchmarkRunner.Run <Stress>();

                return;
            }

            Console.WriteLine($"Command Line: {cmd}");

            if (cmd.IsServer)
            {
                StartServer();

                StartClients(cmd);
            }

            if (cmd.IsClient)
            {
                BeginClient(cmd);
            }

            var waits = ProcessWaits.Select(p => new ProcessWaitHandle(p)).ToArray();

            WaitHandle.WaitAll(waits);

            Teardown();
        }
Exemple #2
0
        static async Task Main(string[] args)
        {
            var cmd = CommandLineParameters.Parse(args);

            if (cmd == null)
            {
                BenchmarkRunner.Run(typeof(Program).Assembly);
                return;
            }

            if (cmd.Benchmark == BenchmarkType.Timing)
            {
                BenchmarkRunner.Run <MessageBenchmarks>();
                return;
            }

            if (cmd.Benchmark == BenchmarkType.Stress)
            {
                BenchmarkRunner.Run <StressAsReq>();
                BenchmarkRunner.Run <StressTgsReq>();
                return;
            }

            if (cmd.Benchmark == BenchmarkType.DH)
            {
                BenchmarkRunner.Run <BCryptDiffieHellmanBenchmarks>();
                return;
            }

            Console.WriteLine($"Command Line: {cmd}");

            if (cmd.IsServer)
            {
                await StartServer();

                StartClients(cmd);
            }

            if (cmd.IsClient)
            {
                BeginClient(cmd);
            }

            var waits = ProcessWaits.Select(p => new ProcessWaitHandle(p)).ToArray();

            WaitHandle.WaitAll(waits);

            Teardown();
        }
Exemple #3
0
        private static void StartClients(CommandLineParameters cmd)
        {
            var workerCount = cmd.WorkerCount ?? 1;

            for (var i = 0; i < workerCount; i++)
            {
                var process = StartClientProcess(new CommandLineParameters
                {
                    ClientIdentifier = Guid.NewGuid().ToString(),
                    ThreadCount      = cmd.ThreadCount <= 0 ? Environment.ProcessorCount * 4 : cmd.ThreadCount,
                    Port             = cmd.Port,
                    RequestCount     = cmd.RequestCount <= 0 ? 1000 : cmd.RequestCount
                });

                ProcessWaits.Add(process);
            }

            Thread.Sleep(TimeSpan.FromSeconds(5));

            WaitForAllProcessesToStart.Set();
        }
Exemple #4
0
        static async Task Main(string[] args)
        {
            var cmd = CommandLineParameters.Parse(args);

            if (cmd == null)
            {
                BenchmarkRunner.Run(typeof(Program).Assembly);
                return;
            }

            if (cmd.Benchmark == BenchmarkType.Timing)
            {
                BenchmarkRunner.Run <MessageBenchmarks>();
                return;
            }

            if (cmd.Benchmark == BenchmarkType.Stress)
            {
                BenchmarkRunner.Run <StressAsReq>();
                BenchmarkRunner.Run <StressTgsReq>();
                return;
            }

            if (cmd.Benchmark == BenchmarkType.DH)
            {
                BenchmarkRunner.Run <BCryptDiffieHellmanBenchmarks>();
                return;
            }

            if (cmd.Benchmark == BenchmarkType.Pac)
            {
                BenchmarkRunner.Run <PacEncodingBenchmarks>();
                return;
            }

            Console.WriteLine($"Command Line: {cmd}");

            if (cmd.IsServer)
            {
                await StartServer();

                StartClients(cmd);

                Console.WriteLine("All clients started");
            }

            if (cmd.IsClient)
            {
                BeginClient(cmd);
            }

            var list = SplitList(ProcessWaits.Select(p => new ProcessWaitHandle(p)).ToList(), 64);

            foreach (var waits in list)
            {
                if (waits.Count > 0)
                {
                    WaitHandle.WaitAll(waits.ToArray());
                }
            }

            Teardown();

            Console.WriteLine("Tearing down");

            if (cmd.IsServer)
            {
                Console.ReadKey();
            }
        }