Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

benchmark: don't stop timer until after workers are done #1407

Merged
merged 1 commit into from
Jul 31, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions benchmark/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ func NewClientConn(addr string, opts ...grpc.DialOption) *grpc.ClientConn {
func runUnary(b *testing.B, benchFeatures Features) {
s := stats.AddStats(b, 38)
nw := &latency.Network{Kbps: benchFeatures.Kbps, Latency: benchFeatures.Latency, MTU: benchFeatures.Mtu}
b.StopTimer()
target, stopper := StartServer(ServerInfo{Addr: "localhost:0", Type: "protobuf", Network: nw}, grpc.MaxConcurrentStreams(uint32(benchFeatures.MaxConcurrentCalls+1)))
defer stopper()
conn := NewClientConn(
Expand Down Expand Up @@ -297,20 +296,19 @@ func runUnary(b *testing.B, benchFeatures Features) {
wg.Done()
}()
}
b.StartTimer()
b.ResetTimer()
for i := 0; i < b.N; i++ {
ch <- i
}
b.StopTimer()
close(ch)
wg.Wait()
b.StopTimer()
conn.Close()
}

func runStream(b *testing.B, benchFeatures Features) {
s := stats.AddStats(b, 38)
nw := &latency.Network{Kbps: benchFeatures.Kbps, Latency: benchFeatures.Latency, MTU: benchFeatures.Mtu}
b.StopTimer()
target, stopper := StartServer(ServerInfo{Addr: "localhost:0", Type: "protobuf", Network: nw}, grpc.MaxConcurrentStreams(uint32(benchFeatures.MaxConcurrentCalls+1)))
defer stopper()
conn := NewClientConn(
Expand Down Expand Up @@ -355,13 +353,13 @@ func runStream(b *testing.B, benchFeatures Features) {
wg.Done()
}()
}
b.StartTimer()
b.ResetTimer()
for i := 0; i < b.N; i++ {
ch <- struct{}{}
}
b.StopTimer()
close(ch)
wg.Wait()
b.StopTimer()
conn.Close()
}
func unaryCaller(client testpb.BenchmarkServiceClient, reqSize, respSize int) {
Expand Down