static void Main(string[] args) { IDataStructure stringStructure = new StringStructure(Config.predefinedStrings); // create folder, delete previous files ArrangeDirectories(); var timer = new Stopwatch(); timer.Start(); if (Config.GenerateFileParallelism > 1) { var files = new List <string>(); Parallel.For(0, Config.GenerateFileParallelism, (i) => { var fileName = Config.WorkDirectory + @"\" + Guid.NewGuid().ToString(); GenerateFile((long)Config.FileSizeToGenerate / Config.GenerateFileParallelism, fileName, stringStructure); files.Add(fileName); }); GC.Collect(); Console.WriteLine($"Chunks generated: {timer.Elapsed}"); ConcatenateFiles(Config.SourceFileName, files); Console.WriteLine($"Chunks concatenated: {timer.Elapsed}"); } else { GenerateFile(Config.FileSizeToGenerate, Config.SourceFileName, stringStructure); } // timer stop timer.Stop(); Console.WriteLine($"Elapsed: {timer.Elapsed}"); Console.ReadKey(); }
public static void Main(string[] args) { // init data comparer here // TODO: move to DI injector if need IDataStructure stringStructure = new StringStructure(); var sw = new Stopwatch(); sw.Start(); File.WriteAllLines(Config.DestinationFileName, File.ReadLines(Config.SourceFileName) .Select(ReadProgress()) .Sorted((int)Config.ChunkFileSize, stringStructure.Comparer) .Select(WriteProgress())); sw.Stop(); Console.WriteLine("Elapsed: " + sw.Elapsed); Console.ReadKey(); }