summaryrefslogtreecommitdiffstats
path: root/vendor/strsim/benches
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:47:55 +0000
commit2aadc03ef15cb5ca5cc2af8a7c08e070742f0ac4 (patch)
tree033cc839730fda84ff08db877037977be94e5e3a /vendor/strsim/benches
parentInitial commit. (diff)
downloadcargo-upstream.tar.xz
cargo-upstream.zip
Adding upstream version 0.70.1+ds1.upstream/0.70.1+ds1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/strsim/benches')
-rw-r--r--vendor/strsim/benches/benches.rs100
1 files changed, 100 insertions, 0 deletions
diff --git a/vendor/strsim/benches/benches.rs b/vendor/strsim/benches/benches.rs
new file mode 100644
index 0000000..b7ba829
--- /dev/null
+++ b/vendor/strsim/benches/benches.rs
@@ -0,0 +1,100 @@
+//! Benchmarks for strsim.
+
+#![feature(test)]
+
+extern crate strsim;
+
+mod benches {
+ use self::test::Bencher;
+ use super::*;
+
+ extern crate test;
+
+ #[bench]
+ fn bench_hamming(bencher: &mut Bencher) {
+ let a = "ACAAGATGCCATTGTCCCCCGGCCTCCTGCTGCTGCTGCTCTCCGGGG";
+ let b = "CCTGGAGGGTGGCCCCACCGGCCGAGACAGCGAGCATATGCAGGAAGC";
+ bencher.iter(|| {
+ strsim::hamming(a, b).unwrap();
+ })
+ }
+
+ #[bench]
+ fn bench_jaro(bencher: &mut Bencher) {
+ let a = "Philosopher Friedrich Nietzsche";
+ let b = "Philosopher Jean-Paul Sartre";
+ bencher.iter(|| {
+ strsim::jaro(&a, &b);
+ })
+ }
+
+ #[bench]
+ fn bench_jaro_winkler(bencher: &mut Bencher) {
+ let a = "Philosopher Friedrich Nietzsche";
+ let b = "Philosopher Jean-Paul Sartre";
+ bencher.iter(|| {
+ strsim::jaro_winkler(&a, &b);
+ })
+ }
+
+ #[bench]
+ fn bench_levenshtein(bencher: &mut Bencher) {
+ let a = "Philosopher Friedrich Nietzsche";
+ let b = "Philosopher Jean-Paul Sartre";
+ bencher.iter(|| {
+ strsim::levenshtein(&a, &b);
+ })
+ }
+
+ #[bench]
+ fn bench_levenshtein_on_u8(bencher: &mut Bencher) {
+ bencher.iter(|| {
+ strsim::generic_levenshtein(&vec![0u8; 30], &vec![7u8; 31]);
+ })
+ }
+
+ #[bench]
+ fn bench_normalized_levenshtein(bencher: &mut Bencher) {
+ let a = "Philosopher Friedrich Nietzsche";
+ let b = "Philosopher Jean-Paul Sartre";
+ bencher.iter(|| {
+ strsim::normalized_levenshtein(&a, &b);
+ })
+ }
+
+ #[bench]
+ fn bench_osa_distance(bencher: &mut Bencher) {
+ let a = "Philosopher Friedrich Nietzsche";
+ let b = "Philosopher Jean-Paul Sartre";
+ bencher.iter(|| {
+ strsim::osa_distance(&a, &b);
+ })
+ }
+
+ #[bench]
+ fn bench_damerau_levenshtein(bencher: &mut Bencher) {
+ let a = "Philosopher Friedrich Nietzsche";
+ let b = "Philosopher Jean-Paul Sartre";
+ bencher.iter(|| {
+ strsim::damerau_levenshtein(&a, &b);
+ })
+ }
+
+ #[bench]
+ fn bench_normalized_damerau_levenshtein(bencher: &mut Bencher) {
+ let a = "Philosopher Friedrich Nietzsche";
+ let b = "Philosopher Jean-Paul Sartre";
+ bencher.iter(|| {
+ strsim::normalized_damerau_levenshtein(&a, &b);
+ })
+ }
+
+ #[bench]
+ fn bench_sorensen_dice(bencher: &mut Bencher) {
+ let a = "Philosopher Friedrich Nietzsche";
+ let b = "Philosopher Jean-Paul Sartre";
+ bencher.iter(|| {
+ strsim::sorensen_dice(&a, &b);
+ })
+ }
+}