Merge pull request #212 from dsymonds/bench
Run benchmark server on localhost interface only.
This commit is contained in:
@ -92,10 +92,11 @@ func (s *testServer) StreamingCall(stream testpb.TestService_StreamingCallServer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartServer starts a gRPC server serving a benchmark service. It returns its
|
// StartServer starts a gRPC server serving a benchmark service on the given
|
||||||
// listen address and a function to stop the server.
|
// address, which may be something like "localhost:0". It returns its listen
|
||||||
func StartServer() (string, func()) {
|
// address and a function to stop the server.
|
||||||
lis, err := net.Listen("tcp", ":0")
|
func StartServer(addr string) (string, func()) {
|
||||||
|
lis, err := net.Listen("tcp", addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
grpclog.Fatalf("Failed to listen: %v", err)
|
grpclog.Fatalf("Failed to listen: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func runUnary(b *testing.B, maxConcurrentCalls int) {
|
func runUnary(b *testing.B, maxConcurrentCalls int) {
|
||||||
s := stats.AddStats(b, 38)
|
s := stats.AddStats(b, 38)
|
||||||
b.StopTimer()
|
b.StopTimer()
|
||||||
target, stopper := StartServer()
|
target, stopper := StartServer("localhost:0")
|
||||||
defer stopper()
|
defer stopper()
|
||||||
conn := NewClientConn(target)
|
conn := NewClientConn(target)
|
||||||
tc := testpb.NewTestServiceClient(conn)
|
tc := testpb.NewTestServiceClient(conn)
|
||||||
@ -58,7 +58,7 @@ func runUnary(b *testing.B, maxConcurrentCalls int) {
|
|||||||
func runStream(b *testing.B, maxConcurrentCalls int) {
|
func runStream(b *testing.B, maxConcurrentCalls int) {
|
||||||
s := stats.AddStats(b, 38)
|
s := stats.AddStats(b, 38)
|
||||||
b.StopTimer()
|
b.StopTimer()
|
||||||
target, stopper := StartServer()
|
target, stopper := StartServer("localhost:0")
|
||||||
defer stopper()
|
defer stopper()
|
||||||
conn := NewClientConn(target)
|
conn := NewClientConn(target)
|
||||||
tc := testpb.NewTestServiceClient(conn)
|
tc := testpb.NewTestServiceClient(conn)
|
||||||
|
@ -28,7 +28,7 @@ func main() {
|
|||||||
grpclog.Fatalf("Failed to serve: %v", err)
|
grpclog.Fatalf("Failed to serve: %v", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
addr, stopper := benchmark.StartServer()
|
addr, stopper := benchmark.StartServer(":0") // listen on all interfaces
|
||||||
grpclog.Println("Server Address: ", addr)
|
grpclog.Println("Server Address: ", addr)
|
||||||
<-time.After(time.Duration(*duration) * time.Second)
|
<-time.After(time.Duration(*duration) * time.Second)
|
||||||
stopper()
|
stopper()
|
||||||
|
Reference in New Issue
Block a user