From 75c9303c68864625866f580945533154b9be3dab Mon Sep 17 00:00:00 2001 From: ValarDragon Date: Thu, 12 Jul 2018 12:59:40 -0700 Subject: [PATCH] tools/tmbench: Fix the end time being used for statistics calculation Previously we were using the time at which all connections closed in statistics, not the time after {duration} seconds. --- CHANGELOG.md | 2 +- tools/tm-bench/main.go | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d7490aeb..698b8226a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ BUG FIXES - NOTE: this is only for URI requests. JSONRPC requests and all responses will use quoted integers (the proto3 JSON standard). - [consensus] Fix halt on shutdown -- [tm_bench] Fix method of computing start time +- [tm_bench] Fix method of computing start time, and end time ## 0.22.1 diff --git a/tools/tm-bench/main.go b/tools/tm-bench/main.go index f8a979fef..1bba389f5 100644 --- a/tools/tm-bench/main.go +++ b/tools/tm-bench/main.go @@ -25,13 +25,13 @@ type statistics struct { } func main() { - var duration, txsRate, connections, txSize int + var durationInt, txsRate, connections, txSize int var verbose bool var outputFormat, broadcastTxMethod string flagSet := flag.NewFlagSet("tm-bench", flag.ExitOnError) flagSet.IntVar(&connections, "c", 1, "Connections to keep open per endpoint") - flagSet.IntVar(&duration, "T", 10, "Exit after the specified amount of time in seconds") + flagSet.IntVar(&durationInt, "T", 10, "Exit after the specified amount of time in seconds") flagSet.IntVar(&txsRate, "r", 1000, "Txs per second to send in a connection") flagSet.IntVar(&txSize, "s", 250, "The size of a transaction in bytes.") flagSet.StringVar(&outputFormat, "output-format", "plain", "Output format: plain or json") @@ -73,7 +73,7 @@ Examples: } logger = log.NewTMLoggerWithColorFn(log.NewSyncWriter(os.Stdout), colorFn) - fmt.Printf("Running %ds test @ %s\n", duration, flagSet.Arg(0)) + fmt.Printf("Running %ds test @ %s\n", durationInt, flagSet.Arg(0)) } if broadcastTxMethod != "async" && @@ -105,9 +105,12 @@ Examples: timeStart := time.Now() logger.Info("Time last transacter started", "t", timeStart) - endTime := time.Duration(duration) * time.Second + duration := time.Duration(durationInt) * time.Second - <-time.After(endTime) + timeEnd := timeStart.Add(duration) + logger.Info("End time for calculation", "t", timeEnd) + + <-time.After(duration) for i, t := range transacters { t.Stop() numCrashes := countCrashes(t.connsBroken) @@ -116,15 +119,14 @@ Examples: } } - timeStop := time.Now() - logger.Info("Time stopped", "t", timeStop) + logger.Debug("Time all transacters stopped", "t", time.Now()) stats, err := calculateStatistics( client, initialHeight, timeStart, - timeStop, - duration, + timeEnd, + durationInt, ) if err != nil { fmt.Fprintln(os.Stderr, err)