Skip to content

anderj017/levenshtein

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

levenshtein

Making rust as fast as it can go

Improving the performance of the Rust code in Christian's article

  • Baseline: 2.077593106
  • 6ff99a5: &str.chars().count() -> &str.len(): 2.022744823
  • 1dede2f: reuse same vector: 1.880497681
  • 6adaf13: build cache without .collect(): 1.7518643919999999

And breaking some of Christian's rules:

  • 92d0b82: remove vector bounds checks: 1.475065986
  • 23a7604: pre-allocate vector 100 chars: 1.455840814
  • 7f47ea9: add notes of some interesting findings
  • 73bdea8: use Wrapping to avoid int overflow checks (no real difference)
  • 03f9200: eliminate branches (no real difference)

Interesting findings:

  • Vector bounds checks are surprisingly expensive
  • Rust's opt-in performance improvements look rather ugly :(
  • std::cmp::min has poor performance compared to a hand written function (which was included in the Baseline). This is rather curious and concerning.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages