Created
July 28, 2022 09:05
-
-
Save 9bany/0dcc0f3d61da05d6fc39655baa629451 to your computer and use it in GitHub Desktop.
Generate benchmark files in a Git repository.
This file contains 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
#!/bin/bash | |
# | |
# Generate benchmark files in a Git repository. | |
# | |
# Usage: TIMES=1 go-bench [prefix] | |
# | |
# Number of times to run the benchmark; useful for benchstat. | |
TIMES=${TIMES:-1} | |
# Prefix of the output file; useful for placing in a subdirectory. | |
PREFIX=${1:-benchmark.} | |
# Assume we're in a git repository, so we can remember which commit | |
# was the result of a benchmark. | |
REF=$(git rev-parse --short HEAD) | |
# Generate a file with a timestamp so that we can easily sort the | |
# benchmarks during comparison. | |
FILE="${PREFIX}$(date '+%Y%m%d%H%M')-${REF}.txt" | |
mkdir -p ${PREFIX} | |
function do_bench { | |
for i in $(seq 1 $TIMES); do | |
go test -v -run=^$ -bench=. -benchmem ./... | |
done | |
} | |
do_bench > ${FILE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run benchmark
Out will save in
out
folderCompress all output