github.com/klaytn/klaytn@v1.12.1/tests/calc_tps.sh (about)

     1  #!/bin/bash
     2  DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
     3  BENCHNAME="BenchmarkValueTransfer"
     4  
     5  BENCHTIME=${BENCHTIME:-"5s"}
     6  BENCHCOUNT=${BENCHCOUNT:-5}
     7  
     8  TMP=`mktemp`
     9  
    10  cd $DIR/../tests
    11  
    12  CMD="go test -run X -bench $BENCHNAME -benchtime $BENCHTIME"
    13  echo "executing $CMD for $BENCHCOUNT times"
    14  echo "" > $TMP
    15  for i in `seq 1 $BENCHCOUNT`; do
    16      $CMD | tee -a $TMP
    17  done
    18  NS=`grep "ns/op" $TMP | awk 'BEGIN{total=0.0;count=0} {total+=$3;count++} END{printf("%f", total/count)}'`
    19  TPS=$(echo "1.0 / $NS * 1000.0 * 1000.0 * 1000" | bc -l)
    20  echo "TPS for a single machine = $TPS"
    21  rm -rf $TMP