Ejemplo n.º 1
0
        private static void CalculateTimingsOverIterations(int numIterations, string[] testStrings, IsAsciiDelegate methodToUse)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            for (int i = 0; i < numIterations; i++)
            {
                foreach (var str in testStrings)
                {
                    methodToUse(str);
                }
            }

            stopwatch.Stop();

            Console.WriteLine($"For {numIterations} {methodToUse.Method.Name} took {stopwatch.ElapsedMilliseconds} milliseconds!\n");
        }
Ejemplo n.º 2
0
        private static void ValidateStringsInArrayAndOutputToConsole(string[] testStrings, IsAsciiDelegate methodToUse)
        {
            Console.WriteLine($"Processed using {methodToUse.Method.Name}:");

            foreach (var str in testStrings)
            {
                ValidateTestStringAndOutputToConsole(str, methodToUse);
            }

            Console.WriteLine("\n");
        }
Ejemplo n.º 3
0
        private static void ValidateTestStringAndOutputToConsole(string str, IsAsciiDelegate method)
        {
            var qualifier = method(str) ? string.Empty : " NOT";

            Console.WriteLine($"\"{str}\" is{qualifier} a valid string");
        }
Ejemplo n.º 4
0
 private static void ProcessTestStringsAndOuputSummary(int numIterations, string[] testStrings, IsAsciiDelegate methodToUse)
 {
     ValidateStringsInArrayAndOutputToConsole(testStrings, methodToUse);
     CalculateTimingsOverIterations(numIterations, testStrings, methodToUse);
 }