public void _01_SaveToFile_Perftest_03() { FileName = System.IO.Path.GetTempFileName() + ".txt"; TStrings file = new TStrings(); for (int i = 0; i < 100000; i++) { file.Add(dummy); } ; var dt = DateTime.Now; file.SaveToFile(FileName); var dt1 = DateTime.Now - dt; System.IO.File.Delete(FileName); dt = DateTime.Now; string text = ""; for (int i = 0; i < file.Count; i++) { text = text + file.Get(i); } System.IO.File.WriteAllText(FileName, text); var dt2 = DateTime.Now - dt; Console.WriteLine($"{dt1.TotalMilliseconds} < {dt2.TotalMilliseconds}"); Assert.AreEqual(true, dt1 < dt2); }
public void _01_SaveToFile_Perftest_00() { FileName = System.IO.Path.GetTempFileName() + ".txt"; TStrings file = new TStrings(); for (int i = 0; i < 100000; i++) { file.Add(dummy); } ; var dt = DateTime.Now; file.SaveToFile(FileName); var dt1 = DateTime.Now - dt; System.IO.File.Delete(FileName); dt = DateTime.Now; using (var stream = new FileStream(FileName, FileMode.Create, FileAccess.Write, FileShare.Write)) { using (StreamWriter asw = new StreamWriter(stream, Encoding.Default)) { for (int i = 0; i < file.Count; i++) { asw.WriteLine(file.Get(i)); } }; }; var dt2 = DateTime.Now - dt; Console.WriteLine($"{dt1.TotalMilliseconds} < {dt2.TotalMilliseconds}"); Assert.AreEqual(true, dt1 < dt2); }