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 fae1e31
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 62 deletions.
96 changes: 91 additions & 5 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:
- gcc
- clang
- rust
- fortran
- java
- scala
- kotlin
- ruby
- python3
- node
- deno
- bun
steps:
# clone
- name: Checkout
Expand Down Expand Up @@ -37,10 +52,81 @@ jobs:
with:
deno-version: "~1"
- run: just setup
# do the thing
- run: just count

# build
- if: ${{ matrix.build == "gcc" }}
run: |
gcc -O3 ./count.c
echo './a.out' > CMD
- if: ${{ matrix.build == "clang" }}
run: |
clang -O3 ./count.c
echo './a.out' > CMD
- if: ${{ matrix.build == "rust" }}
run: |
rustc -C opt-level=3 ./count.rs
echo './count' > CMD
- if: ${{ matrix.build == "fortran" }}
run: |
gfortran -O3 ./count.f90
echo './a.out' > CMD
- if: ${{ matrix.build == "java" }}
run: |
javac count.java
echo 'java Count' > CMD
- if: ${{ matrix.build == "scala" }}
run: |
scalac count.scala
echo 'scala Count' > CMD
- if: ${{ matrix.build == "kotlin" }}
run: |
kotlinc count.kt -include-runtime -d count.jar
echo 'java -jar count.jar' > CMD
- if: ${{ matrix.build == "ruby" }}
run: echo 'ruby count.rb' > CMD
- if: ${{ matrix.build == "python3" }}
run: echo 'python3 count.py' > CMD
- if: ${{ matrix.build == "node" }}
run: echo 'node count.js' > CMD
- if: ${{ matrix.build == "deno" }}
run: echo 'deno run count.js' > CMD
- if: ${{ matrix.build == "bun" }}
run: echo 'bun run count.js' > CMD

# bench
- run: |
case "$name" in
*"python"*|*"ruby"*)
args="--runs 1"
;;
*)
args="--warmup 3"
;;
esac
out="${{ matrix.build }}.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")
# report
- run: ls -lah .
- run: ls -lah results
- uses: actions/upload-artifact@v3
with:
name: results
path: results
name: "${{ matrix.build }}.json"
path: "results/${{ matrix.build }}"

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
2 changes: 1 addition & 1 deletion count.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public class count {
public class Count {

public static void main(String[] args){
int i = 0;
Expand Down
56 changes: 0 additions & 56 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 @@ -15,55 +11,3 @@ setup:
cargo install ripgrep --features 'pcre2'
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
#!/usr/bin/env bash
set -euxo pipefail
for f in {{b}}/*; do
sleep 5
name="$(basename $f)"
out="{{r}}/${name}.json"
case "$name" in
*"python"*|*"ruby"*)
args="--runs 2"
;;
*)
args="--warmup 3"
;;
esac
hyperfine $args --shell=none --export-json "$out" "$f"
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
count: all
node ./scripts/summary.js > {{r}}/table.txt
cat {{r}}/table.txt

0 comments on commit fae1e31

Please sign in to comment.