Merge pull request #185 from iamqizhao/master
add pprof port for benchmark client and server
This commit is contained in:
Коммит
d84520d5f9
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче