瀏覽代碼

Merge pull request #4704 from gyuho/print_rate

benchmark: change complete notifier first
Gyu-Ho Lee 9 年之前
父節點
當前提交
969e42c3fa
共有 1 個文件被更改,包括 5 次插入3 次删除
  1. 5 3
      tools/benchmark/cmd/watch.go

+ 5 - 3
tools/benchmark/cmd/watch.go

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