github.com/wI2L/jettison@v0.7.5-0.20230106001914-c70014c6417a/ci/bench.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  set -e
     4  
     5  rm -f .benchruns
     6  rm -f .benchstats.csv
     7  rm -f .benchstats.json
     8  
     9  echo "Starting benchmark..."
    10  
    11  # Execute benchmarks multiple times.
    12  for i in {1..10}
    13  do
    14     echo " + run #$i"
    15     if [ "$CHARTS" == "true" ]; then
    16        go test -short -bench=. >> .benchruns
    17     else
    18        go test -bench=. >> .benchruns
    19     fi
    20  done
    21  
    22  benchstat .benchruns | tee benchstats
    23  
    24  if [ "$CHARTS" == "true" ]; then
    25     echo -e "\nGenerating charts..."
    26  
    27     # Convert benchmark statistics to CSV and
    28     # transform the output to JSON-formatted
    29     # data tables interpretable by Google Charts.
    30     benchstat -csv -norange .benchruns > .benchstats.csv
    31     go run tools/benchparse/benchparse.go -in .benchstats.csv -out .benchstats.json -omit-bandwidth -omit-allocs
    32  
    33     # Generate chart images and apply trim/border
    34     # operations using ImageMagick.
    35     cd tools/charts && npm --silent --no-audit install && cd ../..
    36     node tools/charts/index.js -f .benchstats.json -d images/benchmarks -n Simple,Complex,CodeMarshal,Map
    37  fi
    38  
    39  rm -f .benchruns
    40  rm -f .benchstats.csv
    41  rm -f .benchstats.json