Skip to content

Commit

Permalink
add ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
acheronfail committed Dec 14, 2023
1 parent fae1aef commit fae18af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 6 additions & 0 deletions count.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
i = 0
while i < 1_000_000_000 do
i += 1
end

print i
12 changes: 8 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ build: prepare
rustc -C opt-level=3 ./count.rs -o {{b}}/rust
javac count.java
echo "#!/usr/bin/env -S java count" > {{b}}/java
echo "#!/usr/bin/env -S ruby \n$(cat count.rb)" > {{b}}/ruby
echo "#!/usr/bin/env -S python3 \n$(cat count.py)" > {{b}}/python3
echo "#!/usr/bin/env -S node \n$(cat count.js)" > {{b}}/node
echo "#!/usr/bin/env -S deno run \n$(cat count.js)" > {{b}}/deno
Expand All @@ -41,11 +42,14 @@ run: build
name="$(basename $f)"
out="{{r}}/${name}.json"
if [[ "$name" == *"python"* ]]; then
args="--runs 2"
else
case "$name" in
*"python"*|*"ruby"*)
args="--runs 2"
;;
*)
args="--warmup 3"
fi
;;
esac
hyperfine $args --shell=none --export-json "$out" "$f"
jq '.results[0] | del(.exit_codes)' "$out" | sponge "$out"
Expand Down

0 comments on commit fae18af

Please sign in to comment.