示例#1
0
        /// <summary>
        /// Does a comparison for different techniques of reading all the lines from a file and performing some rudimentary operations on them.
        /// </summary>
        /// <param name="fileName">Tested data file name</param>
        private void ReadAndProcessLinesFromFile(string fileName)
        {
            var fullPath = GetFullTestDataPath(fileName);

            if (File.Exists(fullPath))
            {
                // Get number of lines in file
                var numberOfLines = File.ReadLines(fullPath).Count();
                PrintTestMethodHeader(fileName, numberOfLines);

                // Start all techniques Iterations times and save all process times
                for (int i = 0; i < Iterations; i++)
                {
                    foreach (var method in _methodsToRun)
                    {
                        var partialResult = PartialResults.GetOrCreate(method.Method.Name);
                        var processTime   = RunFileReader(method, fullPath);
                        partialResult.AddProcessTime(processTime);
                    }
                }

                ProcessResults(fileName, numberOfLines);
                GC.Collect();
            }
            else
            {
                Console.WriteLine($"File {fullPath} doesn't exist");
            }
        }
示例#2
0
        /// <summary>
        /// Does a comparison for different collection of adding and sorting all the lines from a file
        /// </summary>
        /// <param name="fileName">Tested data file name</param>
        private void SaveLinesFromFile(string fileName)
        {
            var fullPath = GetFullTestDataPath(fileName);

            if (File.Exists(fullPath))
            {
                // Get number of lines in file
                var numberOfLines = File.ReadLines(fullPath).Count();
                PrintTestMethodHeader(fileName, numberOfLines);

                // Start all techniques Iterations times and save all process times
                for (int i = 0; i < Iterations; i++)
                {
                    foreach (var keyValueCollection in _keyValueCollections)
                    {
                        var partialResultOneCollection = PartialResults.GetOrCreate($"{nameof(T1)} {keyValueCollection.Name}");

                        var processTimeOneCollection = RunProcessFile(T1, fullPath, keyValueCollection, null);
                        partialResultOneCollection.AddProcessTime(processTimeOneCollection);
                        Console.WriteLine();
                        keyValueCollection.Clear();

                        foreach (var uIntCollection in _uIntCollections)
                        {
                            var partialResultTwoCollections = PartialResults.GetOrCreate($"{nameof(T2)} {keyValueCollection.Name} {uIntCollection.Name}");
                            var processTimeTwoCollections   = RunProcessFile(T2, fullPath, keyValueCollection, uIntCollection);
                            partialResultTwoCollections.AddProcessTime(processTimeTwoCollections);
                            Console.WriteLine();
                            uIntCollection.Clear();
                            keyValueCollection.Clear();
                        }
                    }
                }

                ProcessResults(fileName, numberOfLines);
                GC.Collect();
            }
            else
            {
                Console.WriteLine($"File {fullPath} doesn't exist");
            }
        }