static void Main() { var measure = new MeasurementCPU(); if (!Directory.Exists(ConstParams.DirName)) { Directory.CreateDirectory(ConstParams.DirName); } var task = Task.Run(() => { for (int i = 0; i < ConstParams.NumberOfFiles; i++) { using (StreamWriter sw = new StreamWriter($@"{ConstParams.DirName}\{i}.txt")) { sw.WriteLine(GeneratePassword(ConstParams.StringLength)); } } } ); while (task.Status != TaskStatus.RanToCompletion) { measure.Measurement(); } measure.StopStopWatch(); measure.PrintToFile(@".\create.txt", "create seconds"); }
static void Main() { var measure = new MeasurementCPU(); var task = Task.Run(() => { for (int i = 0; i < ConstParams.NumberOfFiles; i++) { File.Delete($@"{ConstParams.DirName}\{i}.txt"); } } ); while (task.Status != TaskStatus.RanToCompletion) { measure.Measurement(); } measure.StopStopWatch(); measure.PrintToFile(@".\delete.txt", "delete seconds"); }
static void Main() { var measure = new MeasurementCPU(); var task = Task.Run(() => { for (int i = 0; i < ConstParams.NumberOfFiles; i++) { using (StreamReader sr = new StreamReader($@"{ConstParams.DirName}\{i}.txt")) { str = sr.ReadToEnd(); } } } ); while (task.Status != TaskStatus.RanToCompletion) { measure.Measurement(); } measure.StopStopWatch(); measure.PrintToFile(@".\openRead.txt", "openRead seconds"); }