only call Sleep if it took us less than 1 sec. to generate txs

This commit is contained in:
Anton Kaliaev
2018-05-08 16:23:29 +04:00
parent 52d3eca67c
commit 80e6e0fa05

View File

@@ -168,7 +168,7 @@ func (t *transacter) sendLoop(connIndex int) {
Params: rawParamsJSON,
})
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)
}
@@ -176,7 +176,9 @@ func (t *transacter) sendLoop(connIndex int) {
}
timeToSend := time.Now().Sub(startTime)
time.Sleep(time.Second - timeToSend)
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