Skip to content

Commit 9fca265

Browse files
authored
Release: Initial benchmarks compared to other implementations in other languages (#13)
1 parent f14274a commit 9fca265

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "simstring_rust"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
description = "A native Rust implementation of the SimString algorithm"
55
license = "MIT"
66
repository = "https://github.com/PyDataBlog/simstring_rs"

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM ubuntu:24.04
2+
3+
WORKDIR /app
4+
5+
RUN apt-get update && \
6+
apt-get install -y software-properties-common && \
7+
add-apt-repository universe && \
8+
apt-get update && \
9+
apt-get install -y build-essential simstring-bin time && \
10+
rm -rf /var/lib/apt/lists/*
11+
12+
COPY benches/data/company_names.txt /app/data/company_names.txt
13+
14+
COPY benches/bench_cpp.sh /app/benchmark.sh
15+
16+
RUN chmod +x /app/benchmark.sh
17+
18+
ENTRYPOINT ["/app/benchmark.sh"]

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,35 @@ To revert to a stable version, ensure your Cargo.toml specifies a specific versi
4848
Here is a basic example of how to use simstring_rs in your Rust project:
4949

5050
```Rust
51-
51+
use simstring_rust::database::HashDB;
52+
use simstring_rust::extractors::CharacterNGrams;
53+
use simstring_rust::measures::Cosine;
54+
55+
fn main() {
56+
let feature_extractor = CharacterNGrams {
57+
n: 2,
58+
padder: " ".to_string(),
59+
};
60+
let measure = Cosine::new();
61+
let mut db = HashDB::new(feature_extractor, measure);
62+
63+
db.insert("hello".to_string());
64+
db.insert("help".to_string());
65+
db.insert("halo".to_string());
66+
db.insert("world".to_string());
67+
68+
let threshold = 0.5;
69+
let results = db.search("hell", threshold);
70+
71+
if results.is_empty() {
72+
println!("No results found with threshold {}", threshold);
73+
} else {
74+
println!("Results with threshold {}:", threshold);
75+
for result in results {
76+
println!("Match: '{}' (score: {})", result.value, result.score);
77+
}
78+
}
79+
}
5280
```
5381

5482
## Contributing

0 commit comments

Comments
 (0)