mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-24 18:21:38 +00:00
tools: Refactor tm-bench (#2570)
* specify time unit for FlushThrottleTimeout in TestP2PConfig Refs #2555 * [tm-bench] refactor code https://github.com/tendermint/tendermint/pull/2405#pullrequestreview-157166387
This commit is contained in:
committed by
Alexander Simmerl
parent
4c0c6e0116
commit
35b671214c
@ -405,7 +405,7 @@ func DefaultP2PConfig() *P2PConfig {
|
|||||||
func TestP2PConfig() *P2PConfig {
|
func TestP2PConfig() *P2PConfig {
|
||||||
cfg := DefaultP2PConfig()
|
cfg := DefaultP2PConfig()
|
||||||
cfg.ListenAddress = "tcp://0.0.0.0:36656"
|
cfg.ListenAddress = "tcp://0.0.0.0:36656"
|
||||||
cfg.FlushThrottleTimeout = 10
|
cfg.FlushThrottleTimeout = 10 * time.Millisecond
|
||||||
cfg.AllowDuplicateIP = true
|
cfg.AllowDuplicateIP = true
|
||||||
return cfg
|
return cfg
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,16 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-kit/kit/log/term"
|
"github.com/go-kit/kit/log/term"
|
||||||
|
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
tmrpc "github.com/tendermint/tendermint/rpc/client"
|
tmrpc "github.com/tendermint/tendermint/rpc/client"
|
||||||
"os/signal"
|
|
||||||
"syscall"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var logger = log.NewNopLogger()
|
var logger = log.NewNopLogger()
|
||||||
@ -53,8 +53,7 @@ Examples:
|
|||||||
|
|
||||||
if verbose {
|
if verbose {
|
||||||
if outputFormat == "json" {
|
if outputFormat == "json" {
|
||||||
fmt.Fprintln(os.Stderr, "Verbose mode not supported with json output.")
|
printErrorAndExit("Verbose mode not supported with json output.")
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
// Color errors red
|
// Color errors red
|
||||||
colorFn := func(keyvals ...interface{}) term.FgBgColor {
|
colorFn := func(keyvals ...interface{}) term.FgBgColor {
|
||||||
@ -71,21 +70,13 @@ Examples:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if txSize < 40 {
|
if txSize < 40 {
|
||||||
fmt.Fprintln(
|
printErrorAndExit("The size of a transaction must be greater than or equal to 40.")
|
||||||
os.Stderr,
|
|
||||||
"The size of a transaction must be greater than or equal to 40.",
|
|
||||||
)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if broadcastTxMethod != "async" &&
|
if broadcastTxMethod != "async" &&
|
||||||
broadcastTxMethod != "sync" &&
|
broadcastTxMethod != "sync" &&
|
||||||
broadcastTxMethod != "commit" {
|
broadcastTxMethod != "commit" {
|
||||||
fmt.Fprintln(
|
printErrorAndExit("broadcast-tx-method should be either 'sync', 'async' or 'commit'.")
|
||||||
os.Stderr,
|
|
||||||
"broadcast-tx-method should be either 'sync', 'async' or 'commit'.",
|
|
||||||
)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -103,10 +94,10 @@ Examples:
|
|||||||
"broadcast_tx_"+broadcastTxMethod,
|
"broadcast_tx_"+broadcastTxMethod,
|
||||||
)
|
)
|
||||||
|
|
||||||
//catch Interrupt and quit tm-bench
|
// Quit when interrupted or received SIGTERM.
|
||||||
go func() {
|
|
||||||
c := make(chan os.Signal, 1)
|
c := make(chan os.Signal, 1)
|
||||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||||
|
go func() {
|
||||||
for sig := range c {
|
for sig := range c {
|
||||||
fmt.Printf("captured %v, exiting...\n", sig)
|
fmt.Printf("captured %v, exiting...\n", sig)
|
||||||
for _, t := range transacters {
|
for _, t := range transacters {
|
||||||
@ -116,7 +107,7 @@ Examples:
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Wait until transacters have begun until we get the start time
|
// Wait until transacters have begun until we get the start time.
|
||||||
timeStart := time.Now()
|
timeStart := time.Now()
|
||||||
logger.Info("Time last transacter started", "t", timeStart)
|
logger.Info("Time last transacter started", "t", timeStart)
|
||||||
|
|
||||||
@ -143,8 +134,7 @@ Examples:
|
|||||||
durationInt,
|
durationInt,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err)
|
printErrorAndExit(err.Error())
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printStatistics(stats, outputFormat)
|
printStatistics(stats, outputFormat)
|
||||||
@ -196,3 +186,8 @@ func startTransacters(
|
|||||||
|
|
||||||
return transacters
|
return transacters
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func printErrorAndExit(err string) {
|
||||||
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user