Browse Source

benchmark: fix watch bench

Xiang Li 9 years ago
parent
commit
2bd5d66596
1 changed files with 6 additions and 4 deletions
  1. 6 4
      tools/benchmark/cmd/watch.go

+ 6 - 4
tools/benchmark/cmd/watch.go

@@ -197,12 +197,14 @@ func doWatch(stream v3.Watcher, requests <-chan string) {
 }
 }
 
 
 func recvWatchChan(wch v3.WatchChan) {
 func recvWatchChan(wch v3.WatchChan) {
-	for range wch {
+	for r := range wch {
 		st := time.Now()
 		st := time.Now()
-		results <- result{duration: time.Since(st), happened: time.Now()}
-		bar.Increment()
+		for range r.Events {
+			results <- result{duration: time.Since(st), happened: time.Now()}
+			bar.Increment()
+			atomic.AddInt32(&nrRecvCompleted, 1)
+		}
 
 
-		atomic.AddInt32(&nrRecvCompleted, 1)
 		if atomic.LoadInt32(&nrRecvCompleted) == int32(eventsTotal) {
 		if atomic.LoadInt32(&nrRecvCompleted) == int32(eventsTotal) {
 			recvCompletedNotifier <- struct{}{}
 			recvCompletedNotifier <- struct{}{}
 			break
 			break