10000 Add benchmarks for blame by ethomson · Pull Request #6920 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content

Add benchmarks for blame #6920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
benchmark: show helpful errors w/o local repo
When running without a local test repository, show a helpful error
message.
  • Loading branch information
ethomson committed Oct 21, 2024
commit 4f40bd9f0964f60558300ccff428f1720a41bf3c
27 changes: 27 additions & 0 deletions tests/benchmarks/benchmark_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ else
OUTPUT_STYLE="auto"
fi

HELP_GIT_REMOTE="https://github.com/git/git"
HELP_LINUX_REMOTE="https://github.com/torvalds/linux"

#
# parse the arguments to the outer script that's including us; these are arguments that
# the `benchmark.sh` passes (or that a user could specify when running an individual test)
Expand Down Expand Up @@ -384,3 +387,27 @@ gitbench() {
hyperfine "${ARGUMENTS[@]}"
rm -rf "${SANDBOX_DIR:?}"
}

# helper script to give useful error messages about configuration
needs_repo() {
REPO="${1}"

if [ "${REPO}" = "" ]; then
echo "usage: needs_repo <repo>" 1>&2
exit 1
fi

REPO_UPPER=$(echo "${1}" | tr '[:lower:]' '[:upper:]')
REPO_URL=$(eval echo "\${BENCHMARK_${REPO_UPPER}_REPOSITORY}")
REPO_REMOTE_URL=$(eval echo "\${HELP_${REPO_UPPER}_REMOTE}")

if [ "${REPO_URL}" = "" ]; then
echo "$0: '${REPO}' repository not configured" 1>&2
echo "" 1>&2
echo "This benchmark needs an on-disk '${REPO}' repository. First, clone the" 1>&2
echo "remote repository ('${REPO_REMOTE_URL}') locally then set," 1>&2
echo "the 'BENCHMARK_${REPO_UPPER}_REPOSITORY' environment variable to the path that" 1>&2
echo "contains the repository locally, then run this benchmark again." 1>&2
exit 1
fi
}
2 changes: 2 additions & 0 deletions tests/benchmarks/blame__git_cached
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

. "$(dirname "$0")/benchmark_helpers.sh"

needs_repo git

gitbench --prepare "clone_repo git && cd git && git reset --hard v2.45.0" \
--warmup 5 \
--chdir "git" \
Expand Down
2 changes: 2 additions & 0 deletions tests/benchmarks/blame__linux_cached
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

. "$(dirname "$0")/benchmark_helpers.sh"

needs_repo linux

gitbench --prepare "clone_repo linux && cd linux && git reset --hard v6.9" \
--warmup 5 \
--chdir "linux" \
Expand Down
0