Skip to content

Using Trie Class for Efficient Text Pattern Searching in C#: net11.0 and a benchmark that searches the text - #2428

Open
vladimir-pecanac-main wants to merge 1 commit into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/83249-csharp-using-trie-class-for-efficient-text-pattern-searching
Open

vladimir-pecanac-main wants to merge 1 commit into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/83249-csharp-using-trie-class-for-efficient-text-pattern-searching

Conversation

@vladimir-pecanac-main

Copy link
Copy Markdown
Collaborator

Moves the Trie sample to net11.0 with BenchmarkDotNet 0.15.8 and xUnit 2.9.3. The Trie class gets ContainsPattern(), which really searches a text for the stored patterns, and GetWordsWithPrefix() for prefix lookups. The benchmark used to time the whole-word Search() on the full text, which failed after one lookup; it now calls ContainsPattern(), runs InProcess with the pattern added in GlobalSetup, returns the find count from every method and adds a string.Contains() baseline. Six new tests bring the total to 22, including one that checks every benchmark method finds the pattern on every iteration.

…d benchmark

Retarget both projects to net11.0 and update BenchmarkDotNet to 0.15.8 and the xUnit packages. Trie gains ContainsPattern(), GetWordsWithPrefix() and a CollectWords() helper. The benchmark runs InProcess, adds the pattern in GlobalSetup, returns the find count from every method, calls ContainsPattern() instead of the whole-word Search() and adds a string.Contains() baseline. Six new tests, including one that checks every benchmark method finds the pattern on every iteration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant