From 2a2dd1075f6614f0eefcdfd1f4f7905df853eef4 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Mon, 20 Jun 2016 10:37:17 -0700 Subject: [PATCH] benchmark: correctly count number of watchers --- tools/benchmark/cmd/watch.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/benchmark/cmd/watch.go b/tools/benchmark/cmd/watch.go index 6909c82d2..6ad08525e 100644 --- a/tools/benchmark/cmd/watch.go +++ b/tools/benchmark/cmd/watch.go @@ -39,6 +39,7 @@ changing the value of the watched keys with concurrent put requests. During the test, each watcher watches (--total/--watchers) keys + (a watcher might watch on the same key multiple times if --watched-key-total is small). @@ -97,7 +98,6 @@ func watchFunc(cmd *cobra.Command, args []string) { binary.PutVarint(k, int64(rand.Intn(watchKeySpaceSize))) } watched[i] = string(k) - numWatchers[watched[i]] = numWatchers[watched[i]] + 1 } requests := make(chan string, totalClients) @@ -126,7 +126,9 @@ func watchFunc(cmd *cobra.Command, args []string) { go func() { for i := 0; i < watchTotal; i++ { - requests <- watched[i%len(watched)] + key := watched[i%len(watched)] + requests <- key + numWatchers[key]++ } close(requests) }()