private static void RunAsClient(string[] args)
        {
            bool withArgs = RunningWithArguments(args);

            try
            {
                var hostName = ReadHostName(args);
                ReadPort(args);
                ShowAppHeader(args, false, hostName);

                var channel = new Channel($"{hostName}:{PORT}", ChannelCredentials.Insecure);
                var client  = new AccountService.AccountServiceClient(channel);

                var count    = 100;
                var runAgain = false;
                do
                {
                    ShowAppHeader(args, false);

                    if (withArgs)
                    {
                        if (args.Length >= 4)
                        {
                            if (!Int32.TryParse(args[4], out count))
                            {
                                count = 10;
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("How many iterations you want to perform?");
                        if (!Int32.TryParse(Console.ReadLine(), out count))
                        {
                            count = 10;
                        }
                    }

                    accClient = client;
                    perfCount = count;

                    NetworkThroughputBenchmark.Perform(new Action(new Program().RunBenchmark), perfCount);

                    if (!withArgs)
                    {
                        Console.WriteLine("Press [A] to run again...");
                        runAgain = (Console.ReadKey(intercept: true).Key == ConsoleKey.A);
                    }
                } while (runAgain);

                channel.ShutdownAsync().Wait();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception encountered: {ex}");
                Console.WriteLine("Press any key to exit...");
                Console.ReadKey(intercept: true);
            }
        }
        public async Task RunAsync()
        {
            Console.Clear();
            Print.White("Please enter server IP:", true);
            Print.Cyan("", true);
            var address = Console.ReadLine();

            if (string.IsNullOrWhiteSpace(address))
            {
                address = NetworkUtils.GetLocalIPAddress();
            }

            var connection = new HubConnection($"http://{address}:{Program.PORT}/");
            var myHub      = connection.CreateHubProxy("ChatHub");

            await connection.Start().ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    Print.Red($"There was an error opening the connection:{task.Exception.GetBaseException()}");
                }
                else
                {
                    Print.Green("Server connection established...");
                }
            });

            myHub.On <string, string>("addMessage", (who, message) =>
            {
                Print.Blue($"{who} :: {message}");
            });

            var count    = 100;
            var runAgain = false;

            do
            {
                Print.White("How many iterations you want to perform?", true); Print.Cyan("");
                if (!Int32.TryParse(Console.ReadLine(), out count))
                {
                    count = 10;
                }
                NetworkThroughputBenchmark.Perform(new Action(() =>
                {
                    myHub.Invoke <string>("Send", address, DateTime.Now.Ticks).Wait();
                }), count);

                Print.White("Press [A] to run again...");
                runAgain = (Console.ReadKey(intercept: true).Key == ConsoleKey.A);
            } while (runAgain);

            connection.Stop();
        }
Example #3
0
        static void Main(string[] args)
        {
            var items = new long[] {
                10000, 10002, 10000, 10009, 10001, 10001, 10000, 10000, 10002, 10001,
                10000, 10002, 10000, 10002, 10001, 10001, 10000, 10000, 10002, 10001
            };

            //var value = new NetworkThroughputBenchmark().Percentile(items, 0.9);

            //Console.WriteLine(value);

            NetworkThroughputBenchmark.ReportMeasures(items, "test");

            Console.ReadKey();
        }
Example #4
0
        private static void Client()
        {
            try
            {
                Console.WriteLine("Enter server IP:");
                var IP = Console.ReadLine();

                if (string.IsNullOrWhiteSpace(IP))
                {
                    IP = Environment.MachineName;
                }

                var wcf = new ServiceProxy();

                {
                    var count    = 100;
                    var runAgain = false;
                    do
                    {
                        Console.Clear();
                        Console.WriteLine("How many iterations you want to perform?");
                        if (!Int32.TryParse(Console.ReadLine(), out count))
                        {
                            count = 10;
                        }

                        instance = wcf;

                        //BenchmarkDotNet.Running.BenchmarkRunner.Run<Program>();
                        NetworkThroughputBenchmark.Perform(new Action(new Program().Execute), count);

                        Console.ResetColor();
                        Console.WriteLine("Press [A] to run again...");
                        runAgain = (Console.ReadKey(intercept: true).Key == ConsoleKey.A);
                    } while (runAgain);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }