summaryrefslogtreecommitdiff
path: root/vendor/github.com/jackc/pgx/v5/internal/sanitize/benchmmark.sh
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2025-03-24 10:50:09 +0000
committerLibravatar GitHub <noreply@github.com>2025-03-24 10:50:09 +0000
commit18c8f85a3032fcc091b4c9e2be6cbe00f80b7f53 (patch)
tree5da21e4f91951c667068ab01c2b3886fc4a5f6a0 /vendor/github.com/jackc/pgx/v5/internal/sanitize/benchmmark.sh
parent[chore]: Bump golang.org/x/net from 0.36.0 to 0.37.0 (#3934) (diff)
downloadgotosocial-18c8f85a3032fcc091b4c9e2be6cbe00f80b7f53.tar.xz
[chore]: Bump github.com/jackc/pgx/v5 from 5.7.2 to 5.7.3 (#3935)
Bumps [github.com/jackc/pgx/v5](https://github.com/jackc/pgx) from 5.7.2 to 5.7.3. - [Changelog](https://github.com/jackc/pgx/blob/master/CHANGELOG.md) - [Commits](https://github.com/jackc/pgx/compare/v5.7.2...v5.7.3) --- updated-dependencies: - dependency-name: github.com/jackc/pgx/v5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/jackc/pgx/v5/internal/sanitize/benchmmark.sh')
-rw-r--r--vendor/github.com/jackc/pgx/v5/internal/sanitize/benchmmark.sh60
1 files changed, 60 insertions, 0 deletions
diff --git a/vendor/github.com/jackc/pgx/v5/internal/sanitize/benchmmark.sh b/vendor/github.com/jackc/pgx/v5/internal/sanitize/benchmmark.sh
new file mode 100644
index 000000000..ec0f7b03a
--- /dev/null
+++ b/vendor/github.com/jackc/pgx/v5/internal/sanitize/benchmmark.sh
@@ -0,0 +1,60 @@
+#!/usr/bin/env bash
+
+current_branch=$(git rev-parse --abbrev-ref HEAD)
+if [ "$current_branch" == "HEAD" ]; then
+ current_branch=$(git rev-parse HEAD)
+fi
+
+restore_branch() {
+ echo "Restoring original branch/commit: $current_branch"
+ git checkout "$current_branch"
+}
+trap restore_branch EXIT
+
+# Check if there are uncommitted changes
+if ! git diff --quiet || ! git diff --cached --quiet; then
+ echo "There are uncommitted changes. Please commit or stash them before running this script."
+ exit 1
+fi
+
+# Ensure that at least one commit argument is passed
+if [ "$#" -lt 1 ]; then
+ echo "Usage: $0 <commit1> <commit2> ... <commitN>"
+ exit 1
+fi
+
+commits=("$@")
+benchmarks_dir=benchmarks
+
+if ! mkdir -p "${benchmarks_dir}"; then
+ echo "Unable to create dir for benchmarks data"
+ exit 1
+fi
+
+# Benchmark results
+bench_files=()
+
+# Run benchmark for each listed commit
+for i in "${!commits[@]}"; do
+ commit="${commits[i]}"
+ git checkout "$commit" || {
+ echo "Failed to checkout $commit"
+ exit 1
+ }
+
+ # Sanitized commmit message
+ commit_message=$(git log -1 --pretty=format:"%s" | tr -c '[:alnum:]-_' '_')
+
+ # Benchmark data will go there
+ bench_file="${benchmarks_dir}/${i}_${commit_message}.bench"
+
+ if ! go test -bench=. -count=10 >"$bench_file"; then
+ echo "Benchmarking failed for commit $commit"
+ exit 1
+ fi
+
+ bench_files+=("$bench_file")
+done
+
+# go install golang.org/x/perf/cmd/benchstat[@latest]
+benchstat "${bench_files[@]}"