Add profiling port for benchmark server
This commit is contained in:
Родитель
ae40153504
Коммит
a239e5e55f
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"math"
|
||||
"net"
|
||||
|
@ -71,7 +70,7 @@ func closeLoop() {
|
|||
close(ch)
|
||||
wg.Wait()
|
||||
conn.Close()
|
||||
fmt.Println(s.String())
|
||||
log.Println(s.String())
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче