github.com/klaytn/klaytn@v1.12.1/tests/profile_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:-1}
     7  TXS_PER_BLOCK=${TXS_PER_BLOCK:-1000}
     8  
     9  TMP=`mktemp`
    10  
    11  cd $DIR/../tests
    12  
    13  CMD="go test -cpuprofile cpu.out -run X -bench $BENCHNAME -benchtime $BENCHTIME"
    14  echo "executing $CMD for $BENCHCOUNT times"
    15  echo "" > $TMP
    16  for i in `seq 1 $BENCHCOUNT`; do
    17      $CMD | tee -a $TMP
    18  done
    19  NS=`grep "ns/op" $TMP | awk 'BEGIN{total=0.0;count=0} {total+=$3;count++} END{printf("%f", total/count)}'`
    20  TPS=$(echo "1.0 / $NS * 1000.0 * 1000.0 * 1000" | bc -l)
    21  echo "TPS for a single machine = $TPS"
    22  rm -rf $TMP
    23  
    24  go tool pprof -http=localhost:6061 ./tests.test cpu.out