작성한 웹 서버의 프로필을 작성하려고했지만 pprof에 처리기 func에 대한 데이터가 없습니다.
julienschmidt가 httprouter package을 사용하고 있으며, 단순히 내 처리기 중 하나를 벤치마킹하고 pprof 프로필을보고 싶습니다.pprof 프로필이 julienschmidtrouter이고 벤치 마크가 프로파일 링 처리기가 아닙니다.
// Configure the server
server := &http.Server{
Addr: ":4000",
Handler: router,
}
go func() {
log.Println(http.ListenAndServe(":6060", nil))
}()
// Start the server
err = server.ListenAndServe()
if err != nil {
panic(err)
}
라우터는 다음과 같이 초기화 : 벤치마킹을 위해, 내가 go-wrk
을 사용하고이 같은 내 웹 서버와 pprof 설정
// Create the httprouter
router := httprouter.New()
// Register all handlers
router.GET("/entities/:type/map", h.UseHandler(&h.ApiGetEntitiesMapRequest{}, p))
을 그리고 내 핸들러는 다음과 같습니다 :
func (req ApiGetEntitiesMapRequest) Handle(r *http.Request, hrp httprouter.Params, p Params) (interface{}, error) {
test := make([]string, 0)
for i := 0; i < 1000; i++ {
test = append(test, "1")
test = append(test, "2")
// Ensure pprof has some time to collect its data
time.Sleep(10)
}
return test, nil
}
이 처리기는 단지 테스트 일 뿐이며 동적으로 추가합니다 슬라이스에 많은 요소. 그 이유는 이러한 동적 할당이 pprof의 힙 프로파일에 표시되는지 테스트하려고합니다.
자, 내가 한 일은이었다
- 내 서버를 시작
- 내 터미널에서 http://localhost:6060/debug/pprof/heap pprof 이동 도구를 실행
- 다음 벤치 마크 이동-WRK -no-C를 실행하여 내 핸들러 -d 5 http://localhost:4000/entities/object/map
요청이 작동하며 내 벤치 마크도 repor 모든 것이 올바르게 처리됩니다. 그러나 png을 pprof 터미널에 입력하면이 그래프 이 표시됩니다.
그래프에는 처리기 및 처리기에서 수행 한 값 비싼 힙 할당에 대한 정보가 없습니다. 내가 도대체 뭘 잘못하고있는 겁니까?