1 //! Benchmarks for strsim.
7 use self::test::Bencher;
10 fn bench_hamming(bencher: &mut Bencher) {
11 let a = "ACAAGATGCCATTGTCCCCCGGCCTCCTGCTGCTGCTGCTCTCCGGGG";
12 let b = "CCTGGAGGGTGGCCCCACCGGCCGAGACAGCGAGCATATGCAGGAAGC";
14 strsim::hamming(a, b).unwrap();
19 fn bench_jaro(bencher: &mut Bencher) {
20 let a = "Philosopher Friedrich Nietzsche";
21 let b = "Philosopher Jean-Paul Sartre";
28 fn bench_jaro_winkler(bencher: &mut Bencher) {
29 let a = "Philosopher Friedrich Nietzsche";
30 let b = "Philosopher Jean-Paul Sartre";
32 strsim::jaro_winkler(a, b);
37 fn bench_levenshtein(bencher: &mut Bencher) {
38 let a = "Philosopher Friedrich Nietzsche";
39 let b = "Philosopher Jean-Paul Sartre";
41 strsim::levenshtein(a, b);
46 fn bench_levenshtein_on_u8(bencher: &mut Bencher) {
48 strsim::generic_levenshtein(&vec![0u8; 30], &vec![7u8; 31]);
53 fn bench_normalized_levenshtein(bencher: &mut Bencher) {
54 let a = "Philosopher Friedrich Nietzsche";
55 let b = "Philosopher Jean-Paul Sartre";
57 strsim::normalized_levenshtein(a, b);
62 fn bench_osa_distance(bencher: &mut Bencher) {
63 let a = "Philosopher Friedrich Nietzsche";
64 let b = "Philosopher Jean-Paul Sartre";
66 strsim::osa_distance(a, b);
71 fn bench_damerau_levenshtein(bencher: &mut Bencher) {
72 let a = "Philosopher Friedrich Nietzsche";
73 let b = "Philosopher Jean-Paul Sartre";
75 strsim::damerau_levenshtein(a, b);
80 fn bench_normalized_damerau_levenshtein(bencher: &mut Bencher) {
81 let a = "Philosopher Friedrich Nietzsche";
82 let b = "Philosopher Jean-Paul Sartre";
84 strsim::normalized_damerau_levenshtein(a, b);
89 fn bench_sorensen_dice(bencher: &mut Bencher) {
90 let a = "Philosopher Friedrich Nietzsche";
91 let b = "Philosopher Jean-Paul Sartre";
93 strsim::sorensen_dice(a, b);