From 3497fcb768ba5c12bc4ead26bb10bb7c237be061 Mon Sep 17 00:00:00 2001 From: iamqizhao Date: Tue, 22 Dec 2015 15:00:37 -0800 Subject: [PATCH] Fix the benchmark client --- benchmark/client/main.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/benchmark/client/main.go b/benchmark/client/main.go index f9e2a83d..e7f0a8fb 100644 --- a/benchmark/client/main.go +++ b/benchmark/client/main.go @@ -92,13 +92,6 @@ func closeLoopUnary() { func closeLoopStream() { s, conn, tc := buildConnection() - stream, err := tc.StreamingCall(context.Background()) - if err != nil { - grpclog.Fatalf("%v.StreamingCall(_) = _, %v", tc, err) - } - for i := 0; i < 100; i++ { - streamCaller(tc, stream) - } ch := make(chan int, *maxConcurrentRPCs*4) var ( mu sync.Mutex @@ -108,7 +101,15 @@ func closeLoopStream() { // Distribute RPCs over maxConcurrentCalls workers. for i := 0; i < *maxConcurrentRPCs; i++ { go func() { - for _ = range ch { + stream, err := tc.StreamingCall(context.Background()) + if err != nil { + grpclog.Fatalf("%v.StreamingCall(_) = _, %v", tc, err) + } + // Do some warm up. + for i := 0; i < 100; i++ { + streamCaller(tc, stream) + } + for range ch { start := time.Now() streamCaller(tc, stream) elapse := time.Since(start)