public void PerformanceOfNFibonacci() { int numFibs = 12; PerformanceHelper.PerformanceTestAction(() => FibonacciIterative().Take(numFibs).ToList(), "FibonacciIterative"); PerformanceHelper.PerformanceTestAction(() => FibonacciRecursive().Take(numFibs).ToList(), "FibonacciRecursive"); PerformanceHelper.PerformanceTestAction(() => Enumerable.Range(0, numFibs).Select(FibonacciN).ToList(), "FibonacciN"); PerformanceHelper.PerformanceTestAction(() => Enumerable.Range(0, numFibs).Select(FibonacciNMemoization).ToList(), "FibonacciNMemoization"); }
public void PerformanceComparisonSmallString() { string s = "smallstring"; string[] t = { "small", "mall", "string", "str", "lls" }; var suffixTree = new SuffixTree(s); var precomputedHashes = new PrecomputedHashes(s); PerformanceHelper.PerformanceTestAction(() => suffixTree.AllExistAsSubstrings(t), "SuffixTree small string"); PerformanceHelper.PerformanceTestAction(() => SearchUsingStringContains(s, t), "String.Contains small string"); PerformanceHelper.PerformanceTestAction(() => precomputedHashes.AllExistAsSubstrings(t), "PrecomputedHashes small string"); }
public void PerformanceComparisonLongString() { string s = "thequickredfoxjumpedoverthelazybrowndogandthatishowyoudoitdontyouknowthattheworldisroundyoushouldyouknowifyoucanuseawebbrowsertonavigatetogithubdotcomandseethistext"; string[] t = { "redfoxjumpedovert", "azybrow", "ndogandthatishowyoudoi", "quickredfoxjum", "oudoitdontyoukn", "otcoman", "useawebbrows", "thequickredfoxjumpedoverthelazybrowndogandthatishowyoudoitdontyouknowthattheworldisroundyoushouldyouknowifyoucanuseawebbrowsertonavigatetogithubdotcomandseethistex", "quickredfoxjumpedoverthelazybrowndogandthatishowyoudoitdontyouknowthattheworldisroundyoushouldyouknowifyoucanuseawebbrowsertonavigatetogithubdotcomandseethistext", "ogandthatishowyoudoitdontyouknowthattheworldisroundyoushouldyouknowifyoucanuseawebbrowsertonavigatetogithubdotcomandseethist" }; var suffixTree = new SuffixTree(s); var precomputedHashes = new PrecomputedHashes(s); int numTimes = 100000; PerformanceHelper.PerformanceTestAction(() => suffixTree.AllExistAsSubstrings(t), "SuffixTree long string", numTimes); PerformanceHelper.PerformanceTestAction(() => SearchUsingStringContains(s, t), "String.Contains long string", numTimes); PerformanceHelper.PerformanceTestAction(() => precomputedHashes.AllExistAsSubstrings(t), "String.Contains long string", numTimes); }