diff --git a/benchmark/client/main.go b/benchmark/client/main.go index 4fe7102d..4bd87a0e 100644 --- a/benchmark/client/main.go +++ b/benchmark/client/main.go @@ -2,8 +2,11 @@ package main import ( "flag" - "fmt" + "log" "math" + "net" + "net/http" + _ "net/http/pprof" "sync" "time" @@ -67,10 +70,20 @@ func closeLoop() { close(ch) wg.Wait() conn.Close() - fmt.Println(s.String()) + log.Println(s.String()) } func main() { flag.Parse() + go func() { + lis, err := net.Listen("tcp", ":0") + if err != nil { + log.Fatalf("Failed to listen: %v", err) + } + log.Println("Client profiling address: ", lis.Addr().String()) + if err := http.Serve(lis, nil); err != nil { + log.Fatalf("Failed to serve: %v", err) + } + }() closeLoop() } diff --git a/benchmark/server/main.go b/benchmark/server/main.go index 7bcfb5c3..d24a4478 100644 --- a/benchmark/server/main.go +++ b/benchmark/server/main.go @@ -2,8 +2,11 @@ package main import ( "flag" - "fmt" + "log" "math" + "net" + "net/http" + _ "net/http/pprof" "time" "google.golang.org/grpc/benchmark" @@ -15,8 +18,18 @@ var ( func main() { flag.Parse() + go func() { + lis, err := net.Listen("tcp", ":0") + if err != nil { + log.Fatalf("Failed to listen: %v", err) + } + log.Println("Server profiling address: ", lis.Addr().String()) + if err := http.Serve(lis, nil); err != nil { + log.Fatalf("Failed to serve: %v", err) + } + }() addr, stopper := benchmark.StartServer() - fmt.Println("Server Address: ", addr) + log.Println("Server Address: ", addr) <-time.After(time.Duration(*duration) * time.Second) stopper() }