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 (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
_ "net/http/pprof"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -67,10 +70,20 @@ func closeLoop() {
|
||||||
close(ch)
|
close(ch)
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
conn.Close()
|
conn.Close()
|
||||||
fmt.Println(s.String())
|
log.Println(s.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
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()
|
closeLoop()
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,11 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
_ "net/http/pprof"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"google.golang.org/grpc/benchmark"
|
"google.golang.org/grpc/benchmark"
|
||||||
|
@ -15,8 +18,18 @@ var (
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
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()
|
addr, stopper := benchmark.StartServer()
|
||||||
fmt.Println("Server Address: ", addr)
|
log.Println("Server Address: ", addr)
|
||||||
<-time.After(time.Duration(*duration) * time.Second)
|
<-time.After(time.Duration(*duration) * time.Second)
|
||||||
stopper()
|
stopper()
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче