#![feature(test)] extern crate test; use test::Bencher; use str_distance::*; #[bench] fn bench_levenshtein(bencher: &mut Bencher) { let a = r##"Writing a list of random sentences is harder than I initially thought it would be. Three generations with six decades of life experience. Pair your designer cowboy hat with scuba gear for a memorable occasion. Wisdom is easily acquired when hiding under the bed with a saucepan on your head. The crowd yells and screams for more memes."##; let b = r##"I caught my squirrel rustling through my gym bag. The efficiency we have at removing trash has made creating trash more acceptable. We have young kids who often walk into our room at night for various reasons including clowns in the closet. It turns out you don't need all that stuff you insisted you did. He didn't understand why the bird wanted to ride the bicyclebicyclebicyclebicyclebicyclebicyclebicycle"##; bencher.iter(|| { DamerauLevenshtein::default().str_distance(a, b); }) } #[bench] fn bench_levenshtein_str_sim(bencher: &mut Bencher) { let a = r##"Writing a list of random sentences is harder than I initially thought it would be. Three generations with six decades of life experience. Pair your designer cowboy hat with scuba gear for a memorable occasion. Wisdom is easily acquired when hiding under the bed with a saucepan on your head. The crowd yells and screams for more memes."##; let b = r##"I caught my squirrel rustling through my gym bag. The efficiency we have at removing trash has made creating trash more acceptable. We have young kids who often walk into our room at night for various reasons including clowns in the closet. It turns out you don't need all that stuff you insisted you did. He didn't understand why the bird wanted to ride the bicyclebicyclebicyclebicyclebicyclebicyclebicycle"##; bencher.iter(|| { strsim::damerau_levenshtein(a, b); }) }