Skip to content

Commit

Permalink
Amend Levenshtrie creation to use Add since it's faster
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjsaid committed Aug 21, 2024
1 parent 305227d commit 5392efe
Show file tree
Hide file tree
Showing 2 changed files with 163 additions and 271 deletions.
26 changes: 24 additions & 2 deletions src/Levenshtypo.Benchmarks/LevenshtrieConstructionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,30 @@ public class LevenshtrieConstructionTests
public object Numbers_Dictionary() => new Dictionary<string, string>(_1000Entries.Select(w => new KeyValuePair<string, string>(w, w)));

[Benchmark]
public object English_Levenshtypo() => Levenshtrie<string>.Create(_englishWords.Select(w => new KeyValuePair<string, string>(w, w)));
public object English_Levenshtypo() => Levenshtrie.Create(_englishWords.Select(w => new KeyValuePair<string, string>(w, w)));

[Benchmark]
public object Numbers_Levenshtypo() => Levenshtrie<string>.Create(_1000Entries.Select(w => new KeyValuePair<string, string>(w, w)));
public object Numbers_Levenshtypo() => Levenshtrie.Create(_1000Entries.Select(w => new KeyValuePair<string, string>(w, w)));

[Benchmark]
public object English_Levenshtypo_Add()
{
var trie = Levenshtrie.CreateEmpty<string>();
foreach (var item in _englishWords)
{
trie.Add(item, item);
}
return trie;
}

[Benchmark]
public object Numbers_Levenshtypo_Add()
{
var trie = Levenshtrie.CreateEmpty<string>();
foreach (var item in _1000Entries)
{
trie.Add(item, item);
}
return trie;
}
}
Loading

0 comments on commit 5392efe

Please sign in to comment.