Merge pull request #185 from iamqizhao/master

add pprof port for benchmark client and server
This commit is contained in:
Qi Zhao 2015-04-30 19:25:48 -07:00
Родитель 576384756c a239e5e55f
Коммит d84520d5f9
2 изменённых файлов: 30 добавлений и 4 удалений

Просмотреть файл

@ -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()
}