Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moar SPEEEED #4

Merged
merged 1 commit into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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