Skip to content

Commit

Permalink
Merge pull request #4 from masmullin2000/main
Browse files Browse the repository at this point in the history
Moar SPEEEED
  • Loading branch information
jinyus authored Sep 23, 2023
2 parents 24fac6d + 93244b6 commit e0d46e9
Show file tree
Hide file tree
Showing 6 changed files with 845 additions and 3 deletions.
40 changes: 37 additions & 3 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,53 @@
# Read the first arg passed to the script
first_arg=$1

HYPER=0
if command -v hyperfine &> /dev/null; then
HYPER=1
fi

run_go() {
echo "Running Go" &&
cd ./go &&
go build &&
command time -f '%es %Mk' ./related
#command time -f '%es %Mk' ./related
if [ $HYPER == 1 ]; then
command hyperfine -w 3 "./related"
else
command time -f '%es %Mk' ./related
fi
}

run_rust() {
echo "Running Rust" &&
cd ./rust &&
cargo build --release &&
command time -f '%es %Mk' ./target/release/rust
if [ $HYPER == 1 ]; then
command hyperfine -w 3 "./target/release/rust"
else
command time -f '%es %Mk' ./target/release/rust
fi
}

run_rust_rayon() {
echo "Running Rust w/ Rayon" &&
cd ./rust_rayon &&
cargo build --release &&
if [ $HYPER == 1 ]; then
command hyperfine -w 3 "./target/release/rust_rayon"
else
command time -f '%es %Mk' ./target/release/rust_rayon
fi
}

run_python() {
echo "Running Python" &&
cd ./python &&
command time -f '%es %Mk' python3 ./related.py
if [ $HYPER == 1 ]; then
command hyperfine -w 3 "python3 ./related.py"
else
command time -f '%es %Mk' python3 ./related.py
fi
}

check_output() {
Expand All @@ -39,6 +68,11 @@ elif [ "$first_arg" = "rust" ]; then
run_rust &&
check_output "related_posts_rust.json"

elif [ "$first_arg" = "rust_ray" ]; then

run_rust_rayon &&
check_output "related_posts_rust_rayon.json"

elif [ "$first_arg" = "python" ]; then

run_python &&
Expand Down
41 changes: 41 additions & 0 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ edition = "2021"
rustc_data_structures = "0.0.1"
serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.107"

[profile.release]
lto = true
codegen-units = 1
Loading

0 comments on commit e0d46e9

Please sign in to comment.