diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 23e2fe4..b7a20be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,18 +13,19 @@ jobs: strategy: matrix: build: - - bun - - clang - - deno - - fortran - - gcc - - java - - kotlin - - node - - python3 - - ruby - - rust - - scala + # - bun + # - clang + # - deno + # - fortran + # - gcc + # - java + # - kotlin + # - node + # - python3 + # - ruby + # - rust + # - scala + - zig steps: - name: Checkout uses: actions/checkout@v3 @@ -49,7 +50,25 @@ jobs: - uses: denoland/setup-deno@v1 with: deno-version: "~1" - - run: just setup + - run: | + sudo apt install -y build-essential cargo clang curl gfortran jq kotlin moreutils nodejs rustc scala tar wget xz-utils + cargo install timers + cargo install hyperfine + cargo install ripgrep --features 'pcre2' + + df -h + mkdir -p /opt/zig && cd $_ + wget --quiet -O zig.tar.xz $(curl --silent https://ziglang.org/download/index.json | jq -r '.[keys_unsorted[1]]["x86_64-linux"].tarball') + tar -xvf zig.tar.xz >/dev/null + zig_path="$PWD/$(tar -tf zig.tar.xz | head -n1)" + echo "$zig_path" >> $GITHUB_PATH + export PATH="$PATH:$zig_path" + cd - + + df -h + echo $PATH + which zig + # do the thing - run: just measure ${{ matrix.build }} # report @@ -64,7 +83,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Download Results - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: path: . - run: sudo apt-get install nodejs diff --git a/.gitignore b/.gitignore index 332904d..9d3ef5f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ build results *.class *.json +*.o java/ kotlin/ scala/ diff --git a/count.zig b/count.zig new file mode 100644 index 0000000..43f6038 --- /dev/null +++ b/count.zig @@ -0,0 +1,7 @@ +const std = @import("std"); + +pub fn main() !void { + var i: u32 = 0; + while (i < 1_000_000_000) : (i += 1) {} + std.debug.print("{}\n", .{i}); +} diff --git a/justfile b/justfile index 625318e..14b577b 100644 --- a/justfile +++ b/justfile @@ -1,15 +1,10 @@ _default: just -l -setup: - #!/usr/bin/env bash - set -euxo pipefail - if [ ! -z "${CI:-}" ]; then - sudo apt-get install build-essential cargo clang curl gfortran jq kotlin moreutils nodejs rustc scala - cargo install timers - cargo install hyperfine - cargo install ripgrep --features 'pcre2' - fi +@_check +CMDS: + echo {{CMDS}} | xargs -n1 sh -c 'if ! command -v $1 >/dev/null 2>&1 /dev/null; then echo "$1 is required!"; exit 1; fi' bash + +setup: (_check "npm") cd scripts && npm install build what: @@ -45,45 +40,48 @@ summary results: # languages -build-gcc: +build-gcc: (_check "gcc") gcc -O3 ./count.c echo './a.out' > CMD -build-clang: +build-clang: (_check "clang") clang -O3 ./count.c echo './a.out' > CMD -build-rust: +build-rust: (_check "rustc") rustc -C opt-level=3 ./count.rs echo './count' > CMD -build-fortran: +build-fortran: (_check "gfortran") gfortran -O3 ./count.f90 echo './a.out' > CMD -build-java: +build-java: (_check "javac java") javac count.java echo 'java count' > CMD -build-scala: +build-scala: (_check "scalac scala") scalac count.scala echo 'scala count' > CMD -build-kotlin: +build-kotlin: (_check "kotlinc java") kotlinc count.kt -include-runtime -d count.jar echo 'java -jar count.jar' > CMD -build-ruby: +build-ruby: (_check "ruby") echo 'ruby count.rb' > CMD -build-python3: +build-python3: (_check "python3") echo 'python3 count.py' > CMD -build-node: +build-node: (_check "node") echo 'node count.js' > CMD -build-deno: +build-deno: (_check "deno") echo 'deno run count.js' > CMD -build-bun: +build-bun: (_check "bun") echo 'bun run count.js' > CMD + +build-zig: (_check "zig") + zig build-exe -O ReleaseFast ./count.zig \ No newline at end of file