Skip to content

Commit a3e32fe

Browse files
authored
feat(ci): Initial benchmark support for original C++ implementation (#54)
* feat(ci): Initial benchmark support for original C++ implementation (including original Python bindings) * chore(benchmarks): switched to generic searches like original implementation does * chore(ci): updated github actions versions
1 parent 005b961 commit a3e32fe

14 files changed

Lines changed: 420575 additions & 140 deletions

.github/workflows/CI.yml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
contents: write
2121
pull-requests: write
2222
steps:
23-
- uses: actions/checkout@v4
23+
- uses: actions/checkout@v5
2424
with:
2525
# On pull requests, check out the head ref so we can commit to it
2626
ref: ${{ github.head_ref }}
@@ -32,7 +32,7 @@ jobs:
3232
sudo apt-get install -y software-properties-common
3333
sudo add-apt-repository universe
3434
sudo apt-get update
35-
sudo apt-get install -y build-essential simstring-bin
35+
sudo apt-get install -y build-essential autoconf automake libtool swig python3-dev simstring-bin
3636
3737
- name: Install Rust toolchain
3838
uses: dtolnay/rust-toolchain@stable
@@ -41,19 +41,19 @@ jobs:
4141
components: rustfmt, clippy
4242

4343
- name: Set up Python
44-
uses: actions/setup-python@v5
44+
uses: actions/setup-python@v6
4545
with:
46-
python-version: "3.13"
46+
python-version: "3.14"
4747

4848
- name: Set up Ruby
4949
uses: ruby/setup-ruby@v1
5050
with:
51-
ruby-version: "3.3"
51+
ruby-version: "3.4"
5252

5353
- name: Set up Julia
5454
uses: julia-actions/setup-julia@v2
5555
with:
56-
version: "1.11"
56+
version: "1"
5757

5858
- name: Cache python dependencies
5959
uses: actions/cache@v4
@@ -97,7 +97,7 @@ jobs:
9797

9898
- name: Post benchmark results to PR
9999
if: github.event_name == 'pull_request'
100-
uses: actions/github-script@v7
100+
uses: actions/github-script@v8
101101
with:
102102
github-token: ${{ secrets.GITHUB_TOKEN }}
103103
script: |
@@ -157,7 +157,7 @@ jobs:
157157
target: aarch64-apple-darwin
158158

159159
steps:
160-
- uses: actions/checkout@v4
160+
- uses: actions/checkout@v5
161161

162162
- name: Install Rust toolchain
163163
uses: dtolnay/rust-toolchain@stable
@@ -183,9 +183,9 @@ jobs:
183183
restore-keys: ${{ runner.os }}-${{ matrix.target }}-cargo-
184184

185185
- name: Set up Python
186-
uses: actions/setup-python@v5
186+
uses: actions/setup-python@v6
187187
with:
188-
python-version: "3.13"
188+
python-version: "3.14t"
189189

190190
- name: Cache python dependencies
191191
uses: actions/cache@v4
@@ -250,8 +250,8 @@ jobs:
250250
matrix:
251251
os: [windows-latest, macos-latest]
252252
steps:
253-
- uses: actions/checkout@v4
254-
- uses: actions/setup-python@v5
253+
- uses: actions/checkout@v5
254+
- uses: actions/setup-python@v6
255255
with:
256256
python-version: "3.10"
257257

@@ -273,8 +273,8 @@ jobs:
273273
name: Build manylinux wheels
274274
runs-on: ubuntu-latest
275275
steps:
276-
- uses: actions/checkout@v4
277-
- uses: actions/setup-python@v5
276+
- uses: actions/checkout@v5
277+
- uses: actions/setup-python@v6
278278
with:
279279
python-version: "3.10"
280280

@@ -305,8 +305,8 @@ jobs:
305305
- os: macos-14
306306
python-version: "3.10"
307307
steps:
308-
- uses: actions/checkout@v4
309-
- uses: actions/setup-python@v5
308+
- uses: actions/checkout@v5
309+
- uses: actions/setup-python@v6
310310
with:
311311
python-version: ${{ matrix.python-version }}
312312

@@ -360,8 +360,8 @@ jobs:
360360
permissions:
361361
id-token: write
362362
steps:
363-
- uses: actions/checkout@v4
364-
- uses: actions/download-artifact@v4
363+
- uses: actions/checkout@v5
364+
- uses: actions/download-artifact@v6
365365
with:
366366
pattern: wheels-*
367367
path: dist
@@ -414,7 +414,7 @@ jobs:
414414
needs: test
415415
runs-on: ubuntu-latest
416416
steps:
417-
- uses: actions/checkout@v4
417+
- uses: actions/checkout@v5
418418

419419
- name: Install Rust toolchain
420420
uses: dtolnay/rust-toolchain@stable
@@ -423,9 +423,9 @@ jobs:
423423
run: cargo run --example basic --release
424424

425425
- name: Set up Python
426-
uses: actions/setup-python@v5
426+
uses: actions/setup-python@v6
427427
with:
428-
python-version: "3.13"
428+
python-version: "3.14"
429429

430430
- name: Cache python dependencies
431431
uses: actions/cache@v4
@@ -459,7 +459,7 @@ jobs:
459459
if: startsWith(github.ref, 'refs/tags/v')
460460
runs-on: ubuntu-latest
461461
steps:
462-
- uses: actions/checkout@v4
462+
- uses: actions/checkout@v5
463463

464464
- name: Install Rust toolchain
465465
uses: dtolnay/rust-toolchain@stable
@@ -481,7 +481,7 @@ jobs:
481481
contents: write
482482
steps:
483483
- name: Checkout code
484-
uses: actions/checkout@v4
484+
uses: actions/checkout@v5
485485
with:
486486
fetch-depth: 0 # get all tags
487487

.github/workflows/coverage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
runs-on: ubuntu-latest
66
steps:
77
- name: Checkout repository
8-
uses: actions/checkout@v4
8+
uses: actions/checkout@v5
99

1010
- name: Install rust
1111
uses: dtolnay/rust-toolchain@stable
@@ -27,7 +27,7 @@ jobs:
2727
sudo apt-get install -y software-properties-common python3-dev
2828
2929
- name: Set up Python
30-
uses: actions/setup-python@v5
30+
uses: actions/setup-python@v6
3131
with:
3232
python-version: "3.14"
3333

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Session.vim
2828
.vscode/
2929
.DS_Store
3030
bench
31+
.simstring_cpp
32+
.simstring_cpp/
33+
benches/.simstring_cpp/
3134
.venv
3235
uv.lock
3336
tests/python/__pycache__

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ License
126126

127127
This project is licensed under the MIT License.
128128

129+
## Benchmarks
130+
131+
The `benches/run_benches.py` harness compares several language bindings (Rust, Python, Julia, Ruby, C++).
132+
133+
- `git`, `autoconf`, `automake`, `libtool`, `make`, `python`, `uv` and a C++ compiler (`g++`) to build the C++ CLI.
134+
135+
The C++ sources are cloned into `benches/.simstring_cpp/` and a local copy of the `simstring` binary is installed
136+
under that directory. If you need to rebuild from scratch, remove `benches/.simstring_cpp/` before re-running the benchmark suite.
137+
129138
## Acknowledgements
130139

131140
Inspired by the [SimString](https://www.chokkan.org/software/simstring/) project.

benches/bench.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function bench_search(results::Vector)
5555
for threshold in [0.6, 0.7, 0.8]
5656
b = @benchmarkable begin
5757
for term in $search_terms
58-
SimString.search(SimString.Cosine(), $db, term; α=$threshold, ranked=true)
58+
SimString.search(SimString.Cosine(), $db, term; α=$threshold, ranked=false)
5959
end
6060
end samples=100 seconds=20
6161

benches/bench.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def bench_search(results: list):
9898

9999
def benchmark_iteration():
100100
for term in search_terms:
101-
searcher.ranked_search(term, threshold)
101+
searcher.search(term, threshold)
102102

103103
duration = measure_time(benchmark_iteration)
104104
measurements.append(duration)

benches/bench.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def bench_search(results)
6262
while Time.now - start_time < 20 && iterations < 100
6363
time = Benchmark.realtime do
6464
search_terms.each do |term|
65-
matcher.ranked_search(term, threshold)
65+
matcher.search(term, threshold)
6666
end
6767
end
6868
measurements << time

benches/bench.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,14 @@ fn bench_insert(results: &mut Vec<BenchmarkResult>) {
4848
let mut iteration = 0;
4949

5050
while start_time.elapsed() < Duration::from_secs(20) && iteration < 100 {
51-
let setup_start = Instant::now();
5251
let fe = Arc::new(CharacterNgrams::new(*ngram_size, " "));
5352
let mut db = HashDb::new(fe);
54-
let setup_duration = setup_start.elapsed();
5553

5654
let start = Instant::now();
5755
for company in &companies {
5856
db.insert(company.clone());
5957
}
60-
let duration = start.elapsed() - setup_duration;
58+
let duration = start.elapsed();
6159
measurements.push(duration.as_secs_f64() * 1000.0);
6260
iteration += 1;
6361
}
@@ -114,7 +112,7 @@ fn bench_search(results: &mut Vec<BenchmarkResult>) {
114112
while start_time.elapsed() < Duration::from_secs(20) && iteration < 100 {
115113
let start = Instant::now();
116114
for term in &search_terms {
117-
let _ = searcher.ranked_search(term, *threshold).unwrap();
115+
let _ = searcher.search(term, *threshold).unwrap();
118116
}
119117
let duration = start.elapsed();
120118
measurements.push(duration.as_secs_f64() * 1000.0);

benches/bench_cpp.sh

Lines changed: 0 additions & 104 deletions
This file was deleted.

benches/bench_rust.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def bench_search(results: list):
9393

9494
def benchmark_iteration():
9595
for term in search_terms:
96-
searcher.ranked_search(term, threshold)
96+
searcher.search(term, threshold)
9797

9898
duration = measure_time(benchmark_iteration)
9999
measurements.append(duration)

0 commit comments

Comments
 (0)