private static void TestGetPalindromes(string text) { var sw = new Stopwatch(); SimpleImplementation.count = 0; sw.Restart(); var expected = SimpleImplementation.GetPalindromes(text).ToArray(); sw.Stop(); var simpleCount = SimpleImplementation.count; var simpleTime = sw.Elapsed; Implementation1.count = 0; sw.Restart(); var actual = Implementation1.GetPalindromes(text).ToArray(); sw.Stop(); var newCount = Implementation1.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 TestGetPalindromes(string text) { var expected = SimpleImplementation.GetPalindromes(text).OrderBy(x => x).ToArray(); var actual = Implementation1.GetPalindromes(text).OrderBy(x => x).ToArray(); if (!expected.SequenceEqual(actual)) { Console.WriteLine("error GetPalindromes"); Console.WriteLine(string.Join(", ", expected)); Console.WriteLine(string.Join(", ", actual)); } }