private static void TestGetPalindromes(string text) { var sw = new Stopwatch(); Implementation1.count = 0; sw.Restart(); var expected = Implementation1.GetPalindromes(text).ToArray(); sw.Stop(); var simpleCount = Implementation1.count; var simpleTime = sw.Elapsed; Implementation2.count = 0; sw.Restart(); var actual = Implementation2.GetPalindromes(text).ToArray(); sw.Stop(); var newCount = Implementation2.count; var newTime = sw.Elapsed; Console.WriteLine("べた実装 {0}, {2}. 新実装 {1}, {3}", simpleCount, newCount, simpleTime, newTime); if (!expected.OrderBy(x => x).SequenceEqual(actual.OrderBy(x => x))) { Console.WriteLine("error GetPalindromes"); Console.WriteLine(string.Join(", ", expected)); Console.WriteLine(string.Join(", ", actual)); } }
private static void TestGetSubstrings(string text) { var expected = SimpleImplementation.GetSubstrings(text).ToArray(); var actual = Implementation2.GetSubstrings(text).ToArray(); if (!expected.OrderBy(x => x).SequenceEqual(actual.OrderBy(x => x))) { Console.WriteLine("error GetSbustrings"); } }