Skip to content

Commit

Permalink
par_iter to go even faster!
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Aug 26, 2021
1 parent 724ff0d commit f2232a4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions BENCHMARKING.md
Expand Up @@ -213,3 +213,23 @@ Summary
'./result/bin/similar-sort define < /usr/share/dict/words' ran
3.07 ± 0.08 times faster than './go-result/bin/similar-sort benchmark < /usr/share/dict/words'
```

## Coda II

Well, turns out I forgot to have the program calculate the edit distance in parallel.
It's even faster now!

```
$ hyperfine -L impl iter,par_iter './{impl}/bin/similar-sort benchmark < /usr/share/dict/words'
Benchmark #1: ./iter/bin/similar-sort benchmark < /usr/share/dict/words
Time (mean ± σ): 118.6 ms ± 2.2 ms [User: 102.4 ms, System: 15.7 ms]
Range (min … max): 113.9 ms … 123.3 ms 24 runs
Benchmark #2: ./par_iter/bin/similar-sort benchmark < /usr/share/dict/words
Time (mean ± σ): 91.7 ms ± 2.1 ms [User: 247.9 ms, System: 113.5 ms]
Range (min … max): 88.3 ms … 95.6 ms 31 runs
Summary
'./par_iter/bin/similar-sort benchmark < /usr/share/dict/words' ran
1.29 ± 0.04 times faster than './iter/bin/similar-sort benchmark < /usr/share/dict/words'
```
4 changes: 2 additions & 2 deletions src/main.rs
Expand Up @@ -64,7 +64,7 @@ fn try_main() -> Result<()> {

if matches.is_present("jaro-winkler") {
let mut distances: Vec<(f64, &String)> = lines
.iter()
.par_iter()
.map(|candidate| (jaro_winkler(target, candidate), candidate))
.collect();

Expand All @@ -88,7 +88,7 @@ fn try_main() -> Result<()> {
} else {
// levenshtein, the default
let mut distances: Vec<(usize, &String)> = lines
.iter()
.par_iter()
.map(|candidate| (levenshtein(target, candidate), candidate))
.collect();

Expand Down

0 comments on commit f2232a4

Please sign in to comment.