Skip to content

Commit

Permalink
add benchmark scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
vemonet committed Dec 17, 2023
1 parent fb1b91a commit f57e5b4
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
33 changes: 33 additions & 0 deletions scripts/benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -e

# Install:
# HYPERFINE_VERSION="1.12.0"
# wget https://github.com/sharkdp/hyperfine/releases/download/v${HYPERFINE_VERSION}/hyperfine_${HYPERFINE_VERSION}_amd64.deb
# sudo dpkg -i hyperfine_${HYPERFINE_VERSION}_amd64.deb

source .venv/bin/activate

pip install --upgrade curies

maturin develop --release -m python/Cargo.toml
maturin build --release -m python/Cargo.toml
pip install --no-index --find-links=target/wheels/ curies-rs

# m = number of run
hyperfine -m 6 --warmup 3 --export-markdown benchmark.md \
'python scripts/benchmark_rust.py' \
'python scripts/benchmark_python.py'


# Benchmark 1: python scripts/benchmark_rust.py
# Time (mean ± σ): 463.6 ms ± 24.1 ms [User: 217.4 ms, System: 38.3 ms]
# Range (min … max): 438.4 ms … 499.7 ms 6 runs

# Benchmark 2: python scripts/benchmark_python.py
# Time (mean ± σ): 11.232 s ± 1.557 s [User: 10.847 s, System: 0.060 s]
# Range (min … max): 10.094 s … 14.161 s 6 runs

# Summary
# 'python scripts/benchmark_rust.py' ran
# 24.23 ± 3.59 times faster than 'python scripts/benchmark_python.py'
9 changes: 9 additions & 0 deletions scripts/benchmark_python.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import curies

# converter = curies.get_bioregistry_converter()
url = "https://raw.githubusercontent.com/biopragmatics/bioregistry/main/exports/contexts/bioregistry.epm.json"
converter = curies.load_extended_prefix_map(url)

curie = converter.compress("http://purl.obolibrary.org/obo/DOID_1234")

print(curie)
8 changes: 8 additions & 0 deletions scripts/benchmark_rust.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from curies_rs import Converter

url = "https://raw.githubusercontent.com/biopragmatics/bioregistry/main/exports/contexts/bioregistry.epm.json"
converter = Converter.load_extended_prefix_map(url)

curie = converter.compress("http://purl.obolibrary.org/obo/DOID_1234")

print(curie)

0 comments on commit f57e5b4

Please sign in to comment.