diff --git a/flake.nix b/flake.nix index 02a182a..4a1bb59 100644 --- a/flake.nix +++ b/flake.nix @@ -49,6 +49,44 @@ zig fmt --check . ''; + # nix run .#bench + apps.bench = with env.pkgs; env.app ([git coreutils gnutar] ++ optionals (stdenv.isLinux) [poop]) '' + set -e + + tmpdir="$(mktemp -d)" + trap 'rm -rf "$tmpdir"' EXIT + + [[ "$(uname)" == "Linux" ]] && zig build -Daio:posix=disable -p "$tmpdir/new-uring" + zig build -Daio:posix=force -p "$tmpdir/new-posix" + + git archive "''${COMMIT:-HEAD~1}" | tar x -C "$tmpdir" + cd "$tmpdir" + + [[ "$(uname)" == "Linux" ]] && zig build -Daio:posix=disable -p "$tmpdir/old-uring" + zig build -Daio:posix=force -p "$tmpdir/old-posix" + + all=(old-posix/bench/*) + for bench in "''${@:-''${all[@]}}"; do + base="$(basename "$bench")" + [[ -f "new-posix/bench/$base" ]] || continue + if [[ "''${POOP:-0}" == 1 ]]; then + poop "old-uring/bench/$base" "new-uring/bench/$base" + poop "old-posix/bench/$base" "new-posix/bench/$base" + else + if [[ "$(uname)" == "Linux" ]]; then + echo "$base: old-uring" + "old-uring/bench/$base" + echo "$base: new-uring" + "new-uring/bench/$base" + fi + echo "$base: old-posix" + "old-posix/bench/$base" + echo "$base: new-posix" + "new-posix/bench/$base" + fi + done + ''; + # nix run .#deps apps.deps = env.showExternalDeps;