github.com/bigzoro/my_simplechain@v0.0.0-20240315012955-8ad0a2a29bb9/tools/deploy/tx_stat.sh (about) 1 #!/bin/bash 2 3 #要连接的管道文件路径 4 filePath="http://192.168.4.35:5545" 5 6 command="./sipe" 7 8 #常规文件 9 if [ ! -f $command ];then 10 echo "$command not exists" 11 exit 1 12 fi 13 14 start=$1 15 16 if [ -z $1 ];then 17 start=1 18 fi 19 20 end=$2 21 22 if [ -z $2 ];then 23 end=100 24 fi 25 26 blockNumber=$($command attach $filePath --exec="eth.blockNumber") 27 28 if [ $end -gt $blockNumber ];then 29 end=$blockNumber 30 fi 31 32 first=0 33 34 last=0 35 36 txs=0 37 38 for((i=start;i<=end;i++)) 39 do 40 timestamp=$($command attach $filePath --exec="eth.getBlock($i).timestamp") 41 if [ $i -eq $start ];then 42 first=$timestamp 43 fi 44 txSize=$($command attach $filePath --exec="eth.getBlock($i).transactions.length") 45 txs=$((txs+txSize)) 46 if [ $i -eq $end ];then 47 last=$timestamp 48 fi 49 dateTime=$(date -d @"${timestamp}" '+%Y-%m-%d %H:%M:%S') 50 echo "dateTime ${dateTime} block $i has $txSize transactions" 51 done 52 53 #必须四则运算的符号前后必须有空格 54 delta=`expr $last - $first` 55 56 #必须四则运算的符号前后必须有空格 57 tps=`expr $txs / $delta` 58 59 60 blocks=`expr $end - $start` 61 62 63 echo "blocks=$blocks,txs=$txs; last=$last; first=$first;tps=$tps;delta=$delta seconds" 64