Last active
December 9, 2021 14:36
-
-
Save infokiller/dc3755ec4a424bf9aa5363e287b94df1 to your computer and use it in GitHub Desktop.
delta issue #824 reproduction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# See https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ | |
set -o errexit -o errtrace -o nounset -o pipefail | |
build_oci_img () { | |
docker build "$@" - <<'EOF' | |
FROM archlinux | |
RUN pacman -Sy > /dev/null | |
RUN pacman -S --noconfirm --needed coreutils curl gcc bc git > /dev/null | |
ENV CARGO_HOME=/usr/local | |
RUN curl -fsSL 'https://sh.rustup.rs' | sh -s -- -y --profile minimal | |
RUN /usr/local/bin/cargo install --version 0.10.2 git-delta && cp /usr/local/bin/delta /usr/local/bin/delta-0.10.2 | |
RUN /usr/local/bin/cargo install --version 0.11.0 git-delta && cp /usr/local/bin/delta /usr/local/bin/delta-0.11.0 | |
RUN /usr/local/bin/cargo install --version 0.11.2 git-delta && cp /usr/local/bin/delta /usr/local/bin/delta-0.11.2 | |
WORKDIR /repo | |
EOF | |
} | |
main() { | |
build_oci_img | |
docker run --rm -i "$(build_oci_img -q)" bash <<'EOF' | |
benchmark-command() { | |
local num_runs="${1:-100}" | |
shift | |
local before | |
before=$(($(date +%s%N) / 1000000)) | |
printf 'Running command "%s" %d times\n' "$*" "${num_runs}" | |
for _ in $(seq 1 "${num_runs}"); do | |
eval -- "$@" > /dev/null | |
done | |
local after | |
after=$(($(date +%s%N) / 1000000)) | |
local per_run | |
per_run=$(bc < <(printf 'scale=2; %d/%d\n' $((after - before)) "${num_runs}")) | |
echo "${per_run} ms per run ($((after - before)) ms total)" | |
} | |
benchmark-delta-versions() { | |
for v in 0.10.2 0.11.0 0.11.2; do | |
echo "Benchmarking version: $v" | |
benchmark-command 10 "git diff --no-index a b | delta-${v} >| delta-${v}-result" | |
done | |
} | |
main() { | |
echo aaa > a | |
echo aab > b | |
git diff --no-index a b | delta | |
benchmark-delta-versions | |
echo "Spinning up 5000 processes" | |
for i in {1..5000}; do | |
nohup sleep 30 & &> /dev/null | |
done | |
echo "Process counts:" | |
ps --no-headers -e -o fname | sort | uniq -c | |
benchmark-delta-versions | |
} | |
main | |
EOF | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment