From 373a04a181dcc2bc237fd9da7860a503ecd070ea Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Tue, 11 Apr 2017 18:34:48 -0700 Subject: [PATCH] tools/benchmark: fix misc gofmt warnings ref. https://golang.org/cmd/gofmt/#hdr-The_simplify_command Signed-off-by: Gyu-Ho Lee --- tools/benchmark/cmd/lease.go | 2 +- tools/benchmark/cmd/put.go | 30 +++++++++++------------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/tools/benchmark/cmd/lease.go b/tools/benchmark/cmd/lease.go index 4c21f9f7b..8743ed27e 100644 --- a/tools/benchmark/cmd/lease.go +++ b/tools/benchmark/cmd/lease.go @@ -59,7 +59,7 @@ func leaseKeepaliveFunc(cmd *cobra.Command, args []string) { if err != nil { panic(err) } - for _ = range requests { + for range requests { st := time.Now() _, err := c.KeepAliveOnce(context.TODO(), resp.ID) r.Results() <- report.Result{Err: err, Start: st, End: time.Now()} diff --git a/tools/benchmark/cmd/put.go b/tools/benchmark/cmd/put.go index 57d8564d0..760c032eb 100644 --- a/tools/benchmark/cmd/put.go +++ b/tools/benchmark/cmd/put.go @@ -129,26 +129,18 @@ func putFunc(cmd *cobra.Command, args []string) { } func compactKV(clients []*v3.Client) { - var curRev int64 - for _, c := range clients { - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) - resp, err := c.KV.Get(ctx, "foo") - cancel() - if err != nil { - panic(err) - } - curRev = resp.Header.Revision - break + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + resp, err := clients[0].KV.Get(ctx, "foo") + cancel() + if err != nil { + panic(err) } - revToCompact := max(0, curRev-compactIndexDelta) - for _, c := range clients { - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) - _, err := c.KV.Compact(ctx, revToCompact) - cancel() - if err != nil { - panic(err) - } - break + revToCompact := max(0, resp.Header.Revision-compactIndexDelta) + ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second) + _, err = clients[0].KV.Compact(ctx, revToCompact) + cancel() + if err != nil { + panic(err) } }