Beispiel #1
0
        static void Main(string[] args)
        {
            const int filesToCreate   = 1000;
            const int fileSizeInBytes = 1024 * 10;

            IEnumerable <string> fileNames;

            FileCreator fileCreator = new FileCreator();

            fileNames = GenerateFileNames(filesToCreate);
            fileCreator.BenchmarkSyncronousFileCreation(fileNames, fileSizeInBytes);
            fileCreator.Cleanup(fileNames);

            GC.Collect();
            GC.WaitForPendingFinalizers();

            fileNames = GenerateFileNames(filesToCreate);
            fileCreator.BenchmarkAsyncronousFileCreationInAForeachLoop(fileNames, fileSizeInBytes).Wait();
            fileCreator.Cleanup(fileNames);

            GC.Collect();
            GC.WaitForPendingFinalizers();

            fileNames = GenerateFileNames(filesToCreate);
            fileCreator.BenchmarkAsyncronousFileCreationWithTaskWhenAll(fileNames, fileSizeInBytes).Wait();
            fileCreator.Cleanup(fileNames);

            //Console.ReadKey();
        }