public static double TimePrefixCounting(IPrefixCounter<char[]> counter, char[] s, out int[] count) { var stopwatch = new Stopwatch(); stopwatch.Start(); count = counter.CountPrefixes(s); stopwatch.Stop(); return stopwatch.Elapsed.TotalSeconds; }
private static void TestSimpleTextCounts(IPrefixCounter<char[]> counter, char[] s, int[] expectedCounts) { var n = s.Length; if (expectedCounts.Length != n + 1) { throw new ArgumentException("expectedCounts.Length != s.Length + 1"); } var prefixCounts = counter.CountPrefixes(s); Assert.AreEqual(n + 1, prefixCounts.Length); for (int i = 0; i < n; i++) { Assert.AreEqual(expectedCounts[i], prefixCounts[i]); } }