diff --git a/tm-bench/main.go b/tm-bench/main.go index 8369c632b..4e0802916 100644 --- a/tm-bench/main.go +++ b/tm-bench/main.go @@ -132,6 +132,22 @@ func calculateStatistics(client tmrpc.Client, minHeight int64, timeStart, timeSt os.Exit(1) } + maxHeight := info.LastHeight + diff := maxHeight - minHeight + + blockMetas := info.BlockMetas + offset := len(blockMetas) + for len(blockMetas) < int(diff) { + // get blocks between minHeight and last height + info, err := client.BlockchainInfo(minHeight+int64(offset), 0) + if err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } + blockMetas = append(blockMetas, info.BlockMetas...) + offset = len(blockMetas) + } + numBlocksPerSec := make(map[int64]int64) numTxsPerSec := make(map[int64]int64) // because during some seconds blocks won't be created... @@ -140,7 +156,7 @@ func calculateStatistics(client tmrpc.Client, minHeight int64, timeStart, timeSt numTxsPerSec[i] = 0 } - for _, blockMeta := range info.BlockMetas { + for _, blockMeta := range blockMetas { // check if block was created after timeStart if blockMeta.Header.Time.Before(timeStart) { continue @@ -174,6 +190,9 @@ func calculateStatistics(client tmrpc.Client, minHeight int64, timeStart, timeSt stats.TxsThroughput.Update(n) } + fmt.Println("blocks", numBlocksPerSec) + fmt.Println("txs", numTxsPerSec) + return stats } diff --git a/tm-bench/transacter.go b/tm-bench/transacter.go index 89a18b5f8..dd46c7720 100644 --- a/tm-bench/transacter.go +++ b/tm-bench/transacter.go @@ -176,9 +176,6 @@ func (t *transacter) sendLoop(connIndex int) { } timeToSend := time.Now().Sub(startTime) - if timeToSend < 1*time.Second { - time.Sleep(time.Second - timeToSend) - } logger.Info(fmt.Sprintf("sent %d transactions", t.Rate), "took", timeToSend) case <-pingsTicker.C: // go-rpc server closes the connection in the absence of pings