github.com/neohugo/neohugo@v0.123.8/bench.sh (about) 1 #!/usr/bin/env bash 2 3 # allow user to override go executable by running as GOEXE=xxx make ... 4 GOEXE="${GOEXE-go}" 5 6 # Convenience script to 7 # - For a given branch 8 # - Run benchmark tests for a given package 9 # - Do the same for main 10 # - then compare the two runs with benchcmp 11 12 if (( $# < 1 )); 13 then 14 echo "USAGE: ./bench.sh <git-branch> <package-to-bench> (and <benchmark filter> (regexp, optional))" 15 exit 1 16 fi 17 18 if [ $# -eq 1 ]; then 19 PACKAGE=./... 20 PACKAGEFILE="all" 21 else 22 PACKAGE=./"$2" 23 PACKAGEFILE="$(echo "$2" | sed 's/[\/\.]/-/g')" 24 fi 25 26 27 if [ $# -eq 3 ]; then 28 benchFilter=$3 29 else 30 benchFilter="." 31 fi 32 33 BRANCH="$1" 34 BRANCHFILE="$(echo "$1" | sed 's/[\/\.]/-/g')" 35 36 git checkout "$BRANCH" 37 "${GOEXE}" test -test.run=NONE -bench="$benchFilter" -test.benchmem=true "$PACKAGE" > "/tmp/bench-$PACKAGEFILE-$BRANCHFILE.txt" 38 39 git checkout main 40 "${GOEXE}" test -test.run=NONE -bench="$benchFilter" -test.benchmem=true "$PACKAGE" > "/tmp/bench-$PACKAGEFILE-main.txt" 41 42 benchstat -split xxx "/tmp/bench-$PACKAGEFILE-main.txt" "/tmp/bench-$PACKAGEFILE-$BRANCHFILE.txt"