Skip to content

Commit

Permalink
split up jobs in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
acheronfail committed Dec 18, 2023
1 parent fae107b commit fae16c1
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 53 deletions.
37 changes: 33 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,23 @@ on:
workflow_dispatch:

jobs:
run-all:
run:
runs-on: ubuntu-latest
strategy:
matrix:
build:
- bun
- clang
- deno
- fortran
- gcc
- java
- kotlin
- node
- python3
- ruby
- rust
- scala
steps:
# clone
- name: Checkout
Expand Down Expand Up @@ -37,10 +52,24 @@ jobs:
with:
deno-version: "~1"
- run: just setup

# do the thing
- run: just count
- run: just measure ${{ matrix.build }}

# report
- uses: actions/upload-artifact@v3
with:
name: results
path: results
path: "${{ matrix.build }}.json"

report:
needs: ['run']
runs-on: ubuntu-latest
steps:
- uses: oven-sh/setup-bun@v1
- name: Download Results
uses: actions/download-artifact@v2
with:
path: results
- run: ls -lah .
- run: ls -lah results
# TODO: create report
4 changes: 2 additions & 2 deletions count.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object Count {
object count {
def main(args: Array[String]) = {
var num = 0
while (num < 1_000_000_000) {
while (num < 1000000000) {
num += 1
}

Expand Down
111 changes: 64 additions & 47 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
t := "timers --time=nano"
r := "results"
b := "build"

_default:
just -l

Expand All @@ -16,54 +12,75 @@ setup:
fi
cd scripts && npm install
prepare:
rm -rf {{r}} {{b}}
mkdir {{r}} {{b}}

build: prepare
gcc -O3 ./count.c -o {{b}}/c-gcc
clang -O3 ./count.c -o {{b}}/c-clang
rustc -C opt-level=3 ./count.rs -o {{b}}/rust
gfortran -O3 ./count.f90 -o {{b}}/fortran
javac count.java -d java
mkdir -p scala && scalac count.scala -d scala
kotlinc count.kt -include-runtime -d kotlin/kotlin.jar
echo "#!/usr/bin/env -S scala -classpath scala Count" > {{b}}/scala
echo "#!/usr/bin/env -S java -jar kotlin/kotlin.jar " > {{b}}/kotlin
echo "#!/usr/bin/env -S java -cp 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
echo "#!/usr/bin/env -S bun \n$(cat count.js)" > {{b}}/bun
for f in {{b}}/*; do chmod +x "$f"; done

run what: build
{{b}}/{{what}}

all: build
build what:
just build-{{what}}

run what:
just build {{what}}
@$(cat CMD)

measure what:
#!/usr/bin/env bash
set -euxo pipefail
for f in {{b}}/*; do
sleep 5
name="$(basename $f)"
out="{{r}}/${name}.json"
just build {{what}}

case "$name" in
*"python"*|*"ruby"*)
args="--runs 2"
;;
*)
case "{{what}}" in
*"python"*|*"ruby"*)
args="--runs 1"
;;
*)
args="--warmup 3"
;;
esac
hyperfine $args --shell=none --export-json "$out" "$f"
esac

out="{{what}}.json"

hyperfine $args --shell=none --export-json "$out" "$(cat CMD)"
jq '.results[0] | del(.exit_codes)' "$out" | sponge "$out"
timers "$f" >/dev/null 2> >(jq '. += {"max_rss":'$(rg -oP '(?:max_rss:\s*)(\d+)' -r '$1')'}' "$out" | sponge "$out")

# languages

build-gcc:
gcc -O3 ./count.c
echo './a.out' > CMD

build-clang:
clang -O3 ./count.c
echo './a.out' > CMD

build-rust:
rustc -C opt-level=3 ./count.rs
echo './count' > CMD

build-fortran:
gfortran -O3 ./count.f90
echo './a.out' > CMD

build-java:
javac count.java
echo 'java count' > CMD

build-scala:
scalac count.scala
echo 'scala count' > CMD

build-kotlin:
kotlinc count.kt -include-runtime -d count.jar
echo 'java -jar count.jar' > CMD

build-ruby:
echo 'ruby count.rb' > CMD

build-python3:
echo 'python3 count.py' > CMD

build-node:
echo 'node count.js' > CMD

jq '.results[0] | del(.exit_codes)' "$out" | sponge "$out"
timers "$f" >/dev/null 2> >(jq '. += {"max_rss":'$(rg -oP '(?:max_rss:\s*)(\d+)' -r '$1')'}' "$out" | sponge "$out")
done
build-deno:
echo 'deno run count.js' > CMD

count: all
node ./scripts/summary.js > {{r}}/table.txt
cat {{r}}/table.txt
build-bun:
echo 'bun run count.js' > CMD

0 comments on commit fae16c1

Please sign in to comment.