mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-29 04:31:44 +00:00
Merge pull request #94 from tendermint/tm-bench-improvements
[tm-bench] small fixes and improv.
This commit is contained in:
@ -102,7 +102,7 @@ Examples:
|
|||||||
timeStop := time.Now()
|
timeStop := time.Now()
|
||||||
logger.Info("Time stopped", "t", timeStop)
|
logger.Info("Time stopped", "t", timeStop)
|
||||||
|
|
||||||
stats := calculateStatistics(client, minHeight, timeStart, timeStop)
|
stats := calculateStatistics(client, minHeight, timeStart, timeStop, duration)
|
||||||
|
|
||||||
printStatistics(stats, outputFormat)
|
printStatistics(stats, outputFormat)
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ func latestBlockHeight(client tmrpc.Client) int64 {
|
|||||||
return status.SyncInfo.LatestBlockHeight
|
return status.SyncInfo.LatestBlockHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
func calculateStatistics(client tmrpc.Client, minHeight int64, timeStart, timeStop time.Time) *statistics {
|
func calculateStatistics(client tmrpc.Client, minHeight int64, timeStart, timeStop time.Time, duration int) *statistics {
|
||||||
stats := &statistics{
|
stats := &statistics{
|
||||||
BlocksThroughput: metrics.NewHistogram(metrics.NewUniformSample(1000)),
|
BlocksThroughput: metrics.NewHistogram(metrics.NewUniformSample(1000)),
|
||||||
TxsThroughput: metrics.NewHistogram(metrics.NewUniformSample(1000)),
|
TxsThroughput: metrics.NewHistogram(metrics.NewUniformSample(1000)),
|
||||||
@ -134,7 +134,18 @@ func calculateStatistics(client tmrpc.Client, minHeight int64, timeStart, timeSt
|
|||||||
|
|
||||||
numBlocksPerSec := make(map[int64]int64)
|
numBlocksPerSec := make(map[int64]int64)
|
||||||
numTxsPerSec := make(map[int64]int64)
|
numTxsPerSec := make(map[int64]int64)
|
||||||
|
// because during some seconds blocks won't be created...
|
||||||
|
for i := int64(0); i < int64(duration); i++ {
|
||||||
|
numBlocksPerSec[i] = 0
|
||||||
|
numTxsPerSec[i] = 0
|
||||||
|
}
|
||||||
|
|
||||||
for _, blockMeta := range info.BlockMetas {
|
for _, blockMeta := range info.BlockMetas {
|
||||||
|
// check if block was created after timeStart
|
||||||
|
if blockMeta.Header.Time.Before(timeStart) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// check if block was created before timeStop
|
// check if block was created before timeStop
|
||||||
if blockMeta.Header.Time.After(timeStop) {
|
if blockMeta.Header.Time.After(timeStop) {
|
||||||
break
|
break
|
||||||
|
@ -168,7 +168,7 @@ func (t *transacter) sendLoop(connIndex int) {
|
|||||||
Params: rawParamsJSON,
|
Params: rawParamsJSON,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("%v. Try reducing the connections count and increasing the rate.\n", errors.Wrap(err, "txs send failed"))
|
fmt.Fprintf(os.Stderr, "%v. Try reducing the connections count and increasing the rate.\n", errors.Wrap(err, "txs send failed"))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +176,9 @@ func (t *transacter) sendLoop(connIndex int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
timeToSend := time.Now().Sub(startTime)
|
timeToSend := time.Now().Sub(startTime)
|
||||||
|
if timeToSend < 1*time.Second {
|
||||||
time.Sleep(time.Second - timeToSend)
|
time.Sleep(time.Second - timeToSend)
|
||||||
|
}
|
||||||
logger.Info(fmt.Sprintf("sent %d transactions", t.Rate), "took", timeToSend)
|
logger.Info(fmt.Sprintf("sent %d transactions", t.Rate), "took", timeToSend)
|
||||||
case <-pingsTicker.C:
|
case <-pingsTicker.C:
|
||||||
// go-rpc server closes the connection in the absence of pings
|
// go-rpc server closes the connection in the absence of pings
|
||||||
|
Reference in New Issue
Block a user