예제 #1
0
파일: Program.cs 프로젝트: dioptre/cnx
        //____________________________________________________________________________
        static void CalculateTimeRelated(ConfigFileHandler configHandler, SocketClient socketClient)
        {
            long stopTime = 0;

            if (socketClient.completedAllTests == true)
            {
                stopTime = socketClient.stopTime;
            }
            else
            {
                stopTime = DateTime.Now.Ticks;
            }

            if (socketClient.totalCountOfMessagesSent > 0)
            {
                //Display some performance numbers. But when writing to Console, they
                //are useless. So we won't display them then.
                if (Program.consoleWatch == false)
                {
                    long     elapsedTicks    = stopTime - socketClient.startTime;
                    TimeSpan elapsedTime     = new TimeSpan(elapsedTicks);
                    decimal  ticksPerMessage = (decimal)elapsedTicks / (decimal)socketClient.totalCountOfMessagesSent;
                    decimal  msPerMessage    = ticksPerMessage / (decimal)10000;
                    msPerMessage = Math.Round(msPerMessage, 2, MidpointRounding.AwayFromZero);

                    GetPercentageCompleted(configHandler, socketClient);
                    testWriter.WriteLine("Time taken for test was " + elapsedTime);
                    testWriter.WriteLine("ms per message = " + msPerMessage.ToString("#0.00"));
                }
            }
            else
            {
                Console.WriteLine("Something is wrong. No messages sent. Maybe firewall is blocking.");
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: dioptre/cnx
        public static void Main(string[] args)
        {
            // Before the app starts, let's build strings for you to use the console.
            BuildStringsForClientConsole();

            // Get settings and connection info.
            ConfigFileHandler configHandler = new ConfigFileHandler();

            // Start the log writer.
            testWriter = new TestFileWriter(configHandler.saveDirectory);

            // Create one object with a lot of settings, to pass to SocketClient.
            SocketClientSettings socketClientSettings = new SocketClientSettings(configHandler.remoteEndPoint, configHandler.totalNumberOfClientConnectionsToRun, configHandler.numberOfReceivedMessagesPerConnection, Program.maxSimultaneousConnectOps, configHandler.maximumNumberOfSimultaneousClientConnections, Program.receivePrefixLength, configHandler.testBufferSize, Program.sendPrefixLength, Program.opsToPreAlloc);

            // Build the arrays of messages that will be sent, and pass them
            // to the SocketClient object in a stack of arrays.
            MessageArrayController        messageArrayController  = new MessageArrayController(configHandler);
            Stack <OutgoingMessageHolder> stackOfOutgoingMessages = messageArrayController.CreateMessageStack();

            // Create the object that will do most of the work.
            SocketClient socketClient = new SocketClient(socketClientSettings);

            socketClient.GetMessages(stackOfOutgoingMessages);

            // Interact with the console.
            HandleConsoleInteraction(configHandler, socketClient);
        }
예제 #3
0
파일: Program.cs 프로젝트: dioptre/cnx
        //____________________________________________________________________________
        static void CloseProgram(ConfigFileHandler configHandler, SocketClient socketClient)
        {
            CalculateTimeRelated(configHandler, socketClient);

            //Write final message to log.
            if (socketClient.completedAllTests == true)
            {
                Program.testWriter.WriteLine("\r\n\r\nTest successful.  All messages sent.");
            }
            else
            {
                Program.testWriter.WriteLine("\r\n\r\n**********  Test finished with aborted messages  **********");
            }

            //Close log.
            try
            {
                testWriter.Close();
            }
            catch
            {
                Console.WriteLine("Could not close log properly.");
            }
            socketClient.CleanUpOnExit();

            Int32 exitCode = 0;

            if (socketClient.abortTest == true)
            {
                exitCode = 1;
            }
            Environment.Exit(exitCode);
        }
예제 #4
0
파일: Program.cs 프로젝트: dioptre/cnx
        //____________________________________________________________________________
        static void GetPercentageCompleted(ConfigFileHandler configHandler, SocketClient socketClient)
        {
            Double sentCount                   = (Double)socketClient.totalCountOfMessagesSent;
            Double totalMessagesToBeSent       = (Double)configHandler.numberOfSentMessagesPerConnection * (Double)configHandler.totalNumberOfClientConnectionsToRun;
            Double percentOfMessages           = (sentCount / totalMessagesToBeSent) * (Double)100;
            Int64  totalCountOfMessagesAborted = ((Int64)configHandler.numberOfSentMessagesPerConnection * (Int64)configHandler.totalNumberOfClientConnectionsToRun) - socketClient.totalCountOfMessagesSent;

            NumberFormatInfo numFormat = new CultureInfo(CultureInfo.CurrentCulture.ToString(), false).NumberFormat;

            numFormat.NumberDecimalDigits = 0;

            //We'll only write this to log if we are finished.
            if ((socketClient.finished == true) || (socketClient.abortTest == true))
            {
                Program.testWriter.WriteLine("\r\nMessages sent = " + sentCount.ToString("n", numFormat) + ", which is " + percentOfMessages.ToString("#0.00") + "% of total messages to be sent.\r\n# of connection retries = " + socketClient.totalNumberOfConnectionRetries + "\r\nAborted messages =  " + totalCountOfMessagesAborted + "\r\nMax simultaneous connections were " + socketClient.maxSimultaneousClientsThatWereConnected);
            }
            else //write to Console when user types value of checkString
            {
                Console.WriteLine("\r\nMessages sent = " + sentCount.ToString("n", numFormat) + ", which is " + percentOfMessages.ToString("#0.00") + "% of total messages to be sent.\r\n# of connection retries = " + socketClient.totalNumberOfConnectionRetries + "\r\nClient connections finished = " + socketClient.numberOfConnectionsFinishedSuccessfully + ".\r\n" + socketClient.clientsNowConnectedCount + " clients connected to server from this machine.\r\nTest continuing now.\r\n");
            }
        }
예제 #5
0
파일: Program.cs 프로젝트: kcitwm/dova
        public static void Main(string[] args)
        {
            // Before the app starts, let's build strings for you to use the console.
            BuildStringsForClientConsole();

            // Get settings and connection info.
            ConfigFileHandler configHandler = new ConfigFileHandler();
            
            // Start the log writer.
            testWriter = new TestFileWriter(configHandler.saveDirectory);
            
            // Create one object with a lot of settings, to pass to SocketClient.
            SocketClientSettings socketClientSettings = new SocketClientSettings(configHandler.remoteEndPoint, configHandler.totalNumberOfClientConnectionsToRun, configHandler.numberOfReceivedMessagesPerConnection, Program.maxSimultaneousConnectOps, configHandler.maximumNumberOfSimultaneousClientConnections, Program.receivePrefixLength, configHandler.testBufferSize, Program.sendPrefixLength, Program.opsToPreAlloc);

            // Build the arrays of messages that will be sent, and pass them
            // to the SocketClient object in a stack of arrays.            
            MessageArrayController messageArrayController = new MessageArrayController(configHandler);
            Stack<OutgoingMessageHolder> stackOfOutgoingMessages = messageArrayController.CreateMessageStack();

            // Create the object that will do most of the work.
            SocketClient socketClient = new SocketClient(socketClientSettings);
            socketClient.GetMessages(stackOfOutgoingMessages);
            
            // Interact with the console.
            HandleConsoleInteraction(configHandler, socketClient);
        }
예제 #6
0
파일: Program.cs 프로젝트: kcitwm/dova
        //____________________________________________________________________________
        static void GetPercentageCompleted(ConfigFileHandler configHandler, SocketClient socketClient)
        {
            Double sentCount = (Double)socketClient.totalCountOfMessagesSent;
            Double totalMessagesToBeSent = (Double)configHandler.numberOfSentMessagesPerConnection * (Double)configHandler.totalNumberOfClientConnectionsToRun;
            Double percentOfMessages = (sentCount / totalMessagesToBeSent) * (Double)100;
            Int64 totalCountOfMessagesAborted = ((Int64)configHandler.numberOfSentMessagesPerConnection * (Int64)configHandler.totalNumberOfClientConnectionsToRun) - socketClient.totalCountOfMessagesSent;

            NumberFormatInfo numFormat = new CultureInfo(CultureInfo.CurrentCulture.ToString(), false).NumberFormat;
            numFormat.NumberDecimalDigits = 0;

            //We'll only write this to log if we are finished.
            if ((socketClient.finished == true) || (socketClient.abortTest == true))
            {
                Program.testWriter.WriteLine("\r\nMessages sent = " + sentCount.ToString("n", numFormat) + ", which is " + percentOfMessages.ToString("#0.00") + "% of total messages to be sent.\r\n# of connection retries = " + socketClient.totalNumberOfConnectionRetries + "\r\nAborted messages =  " + totalCountOfMessagesAborted + "\r\nMax simultaneous connections were " + socketClient.maxSimultaneousClientsThatWereConnected);
            }
            else //write to Console when user types value of checkString
            {
                Console.WriteLine("\r\nMessages sent = " + sentCount.ToString("n", numFormat) + ", which is " + percentOfMessages.ToString("#0.00") + "% of total messages to be sent.\r\n# of connection retries = " + socketClient.totalNumberOfConnectionRetries + "\r\nClient connections finished = " + socketClient.numberOfConnectionsFinishedSuccessfully + ".\r\n" + socketClient.clientsNowConnectedCount + " clients connected to server from this machine.\r\nTest continuing now.\r\n");
            }
        }        
예제 #7
0
파일: Program.cs 프로젝트: kcitwm/dova
        //____________________________________________________________________________
        static void CalculateTimeRelated(ConfigFileHandler configHandler, SocketClient socketClient)
        {
            long stopTime = 0;
                        
            if (socketClient.completedAllTests == true)
            {
                stopTime = socketClient.stopTime;                
            }
            else
            {
                stopTime = DateTime.Now.Ticks;
            }
            
            if (socketClient.totalCountOfMessagesSent > 0)
            {
                //Display some performance numbers. But when writing to Console, they
                //are useless. So we won't display them then.
                if (Program.consoleWatch == false)
                {
                    long elapsedTicks = stopTime - socketClient.startTime;
                    TimeSpan elapsedTime = new TimeSpan(elapsedTicks);
                    decimal ticksPerMessage = (decimal)elapsedTicks / (decimal)socketClient.totalCountOfMessagesSent;
                    decimal msPerMessage = ticksPerMessage / (decimal)10000;
                    msPerMessage = Math.Round(msPerMessage, 2, MidpointRounding.AwayFromZero);

                    GetPercentageCompleted(configHandler, socketClient);
                    testWriter.WriteLine("Time taken for test was " + elapsedTime);
                    testWriter.WriteLine("ms per message = " + msPerMessage.ToString("#0.00"));
                }
            }            
            else
            {
                Console.WriteLine("Something is wrong. No messages sent. Maybe firewall is blocking.");
            }
        }
예제 #8
0
파일: Program.cs 프로젝트: kcitwm/dova
        //____________________________________________________________________________
        static void CloseProgram(ConfigFileHandler configHandler, SocketClient socketClient)
        {
            CalculateTimeRelated(configHandler, socketClient);

            //Write final message to log.
            if (socketClient.completedAllTests == true)
            {
                Program.testWriter.WriteLine("\r\n\r\nTest successful.  All messages sent.");
            }
            else
            {
                Program.testWriter.WriteLine("\r\n\r\n**********  Test finished with aborted messages  **********");
            }

            //Close log.
            try
            {
                testWriter.Close();

            }
            catch
            {
                Console.WriteLine("Could not close log properly.");
            }
            socketClient.CleanUpOnExit();

            Int32 exitCode = 0;
            if (socketClient.abortTest == true)
            {
                exitCode = 1;
            }
            Environment.Exit(exitCode);
        }
예제 #9
0
파일: Program.cs 프로젝트: kcitwm/dova
        //____________________________________________________________________________
        static void HandleConsoleInteraction(ConfigFileHandler configHandler, SocketClient socketClient)
        {
            string stringToCompare = "";
            string theEntry = "";
            Int32 count = 0;

            // Let's put a little wait here to let the clients finish, so that we
            // will not write irrelevant info to Console if it finishes fast.
            Thread.Sleep(1000);

            while (stringToCompare != closeString)
            {
                if (socketClient.finished == true)
                {
                    if ((count > 0) && (socketClient.abortTest == false))
                    {                        
                        Console.WriteLine("\r\n\r\n*********   " + Program.completedString + "   *********\r\nTo close the program and write log, type '" + Program.closeString + "' and press Enter");
                    }
                }
                else
                {
                    if (watchProgramFlow == true)
                    {
                        Console.WriteLine(wpfTrueString); 
                    }
                    else
                    {
                        Console.WriteLine(wpfFalseString);
                    }
                }

                theEntry = Console.ReadLine().ToUpper(CultureInfo.InvariantCulture);

                switch (theEntry)
                {
                    case checkString:
                        GetPercentageCompleted(configHandler, socketClient);
                        break;
                    case wpf:
                        if ((Program.watchProgramFlow == false) && (socketClient.finished == false))
                        {
                            Program.watchProgramFlow = true;
                            Console.WriteLine("Changed watchProgramFlow to true.");
                            Program.testWriter.WriteLine("\r\nStart logging program flow.\r\n");
                        }
                        else
                        {
                            Console.WriteLine("Program flow was already being logged.");
                        }
                        
                        break;
                    case wpfNo:
                        if ((Program.watchProgramFlow == true) && (socketClient.finished == false))
                        {
                            Program.watchProgramFlow = false;
                            Console.WriteLine("Changed watchProgramFlow to false.");
                            Program.testWriter.WriteLine("\r\nStopped logging program flow.\r\n");
                        }
                        else
                        {
                            Console.WriteLine("Program flow was already NOT being logged.");
                        }                        
                        break;
                    case stopString:
                        if (socketClient.finished == false)
                        {
                            socketClient.abortTest = true;                            
                            Console.WriteLine("test stopped");
                            stringToCompare = closeString;
                        }                                                
                        break;
                    case closeString:
                        stringToCompare = closeString;                        
                        break;
                    default:
                        Console.WriteLine("Unrecognized entry");
                        break;
                }
                count++;
            }
            CloseProgram(configHandler, socketClient);            
        }
예제 #10
0
파일: Program.cs 프로젝트: dioptre/cnx
        //____________________________________________________________________________
        static void HandleConsoleInteraction(ConfigFileHandler configHandler, SocketClient socketClient)
        {
            string stringToCompare = "";
            string theEntry        = "";
            Int32  count           = 0;

            // Let's put a little wait here to let the clients finish, so that we
            // will not write irrelevant info to Console if it finishes fast.
            Thread.Sleep(1000);

            while (stringToCompare != closeString)
            {
                if (socketClient.finished == true)
                {
                    if ((count > 0) && (socketClient.abortTest == false))
                    {
                        Console.WriteLine("\r\n\r\n*********   " + Program.completedString + "   *********\r\nTo close the program and write log, type '" + Program.closeString + "' and press Enter");
                    }
                }
                else
                {
                    if (watchProgramFlow == true)
                    {
                        Console.WriteLine(wpfTrueString);
                    }
                    else
                    {
                        Console.WriteLine(wpfFalseString);
                    }
                }

                theEntry = Console.ReadLine().ToUpper(CultureInfo.InvariantCulture);

                switch (theEntry)
                {
                case checkString:
                    GetPercentageCompleted(configHandler, socketClient);
                    break;

                case wpf:
                    if ((Program.watchProgramFlow == false) && (socketClient.finished == false))
                    {
                        Program.watchProgramFlow = true;
                        Console.WriteLine("Changed watchProgramFlow to true.");
                        Program.testWriter.WriteLine("\r\nStart logging program flow.\r\n");
                    }
                    else
                    {
                        Console.WriteLine("Program flow was already being logged.");
                    }

                    break;

                case wpfNo:
                    if ((Program.watchProgramFlow == true) && (socketClient.finished == false))
                    {
                        Program.watchProgramFlow = false;
                        Console.WriteLine("Changed watchProgramFlow to false.");
                        Program.testWriter.WriteLine("\r\nStopped logging program flow.\r\n");
                    }
                    else
                    {
                        Console.WriteLine("Program flow was already NOT being logged.");
                    }
                    break;

                case stopString:
                    if (socketClient.finished == false)
                    {
                        socketClient.abortTest = true;
                        Console.WriteLine("test stopped");
                        stringToCompare = closeString;
                    }
                    break;

                case closeString:
                    stringToCompare = closeString;
                    break;

                default:
                    Console.WriteLine("Unrecognized entry");
                    break;
                }
                count++;
            }
            CloseProgram(configHandler, socketClient);
        }
예제 #11
0
 public MessageArrayController(ConfigFileHandler theConfigHandler)
 {
     this.configHandler = theConfigHandler;
     stackOfOutgoingMessages = new Stack<OutgoingMessageHolder>(this.configHandler.totalNumberOfClientConnectionsToRun);
 }
 public MessageArrayController(ConfigFileHandler theConfigHandler)
 {
     this.configHandler      = theConfigHandler;
     stackOfOutgoingMessages = new Stack <OutgoingMessageHolder>(this.configHandler.totalNumberOfClientConnectionsToRun);
 }