Skip to content

Commit

Permalink
flake: add bench run step
Browse files Browse the repository at this point in the history
  • Loading branch information
Cloudef committed Jan 31, 2025
1 parent 4b5c0c8 commit b258237
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit b258237

Please sign in to comment.