public void ContainsForSuffixTree() { string s = "thequickredfoxjumpedoverthelazybrowndog"; var suffixTree = new SuffixTree(s); Assert.True(suffixTree.AllExistAsSubstrings(new [] { "azy", "own", "dog", "la", "br", "fox", "thequick" })); Assert.True(suffixTree.AllExistAsSubstrings(new [] { "lazybrowndog", "azybrowndog", "zybrowndog", "ybrowndog" })); Assert.True(suffixTree.AllExistAsSubstrings(new [] { "l", "g", "a", "o" })); }
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 DoesNotContainForSuffixTree() { string s = "thequickredfoxjumpedoverthelazybrowndog"; var suffixTree = new SuffixTree(s); Assert.False(suffixTree.AllExistAsSubstrings(new[] { "purple" })); Assert.False(suffixTree.AllExistAsSubstrings(new[] { "mountain" })); Assert.False(suffixTree.AllExistAsSubstrings(new[] { "majesties" })); Assert.False(suffixTree.AllExistAsSubstrings(new[] { "thequickrd" })); Assert.False(suffixTree.AllExistAsSubstrings(new[] { "dogm" })); Assert.False(suffixTree.AllExistAsSubstrings(new[] { "thequickredfoxjumpedoverthelazybrowndog " })); }
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); }