github.com/aclements/go-misc@v0.0.0-20240129233631-2f6ede80790c/benchscripts/bench-many (about) 1 #!/bin/zsh 2 3 set -e 4 5 if [[ $# != 3 ]]; then 6 echo "usage: bench-many rev-file out-dir iterations" >&2 7 exit 1 8 fi 9 10 revFile=$(realpath $1) 11 outDir=$2 12 iterations=$3 13 mkdir -p $outDir/by-rev 14 mkdir -p $outDir/by-date 15 outDir=$(realpath $outDir) 16 GOROOT=$(go env GOROOT) 17 GOTOOLDIR=$(go env GOTOOLDIR) 18 19 # Build benchmarks 20 cat $revFile | while read rev; do 21 cd $GOROOT 22 rev=$(git rev-parse $rev) 23 revOut=$outDir/by-rev/$rev 24 if [[ -x $revOut/go1.test && -x $revOut/6g && -x $revOut/xbench ]]; then 25 continue 26 fi 27 28 echo "Building $rev" 29 git checkout -q $rev > $outDir/log 30 (cd $GOROOT/src && ./make.bash) >> $outDir/log 2>&1 31 32 if [[ ! -x $revOut/6g ]]; then 33 cp $GOTOOLDIR/6g $revOut/6g 34 fi 35 36 if [[ ! -x $revOut/go1.test ]]; then 37 cd $GOROOT/test/bench/go1 38 go test -c >> $outDir/log 39 mkdir -p $revOut 40 mv go1.test $revOut/go1.test 41 fi 42 43 if [[ ! -x $revOut/xbench ]]; then 44 go build -o $revOut/xbench golang.org/x/benchmarks/bench 45 fi 46 done 47 48 # Make date symlinks 49 cat $revFile | while read rev; do 50 rev=$(git rev-parse $rev) 51 date=$(git log -n1 --format='%cI' $rev | sed 's/+00:00$//') 52 ln -snf ../by-rev/$rev $outDir/by-date/$date 53 done 54 55 # Run benchmarks 56 for i in {1..$iterations}; do 57 cat $revFile | while read rev; do 58 cd $GOROOT 59 rev=$(git rev-parse $rev) 60 cd $outDir/by-rev/$rev 61 logName=go1.out.$(printf %03d $i) 62 if [[ -f $logName ]]; then 63 continue 64 fi 65 echo "$rev ($i)" 66 ./go1.test -test.bench . > go1.out.tmp 67 mv go1.out.tmp $logName 68 done 69 done 70 71 # TODO: Run 6g "benchmark" (with gctrace=1) 72 # TODO: Run x/bench benchmarks (with gctrace=1)