我有一個相對較大的使用Gorilla's mux進行路由的Go應用程序。我最近意識到我的Web應用程序非常慢,我想分析Web應用程序。分析使用Gorilla的多路複用器與網/ http/pprof構建的Go Web應用程序
看完後,它接縫net/http/pprof是我所需要的。但我不能讓它與mux;即使在最瑣碎的Web應用程序的情況下。
有誰知道如何使這項工作?
下面是一個不起作用的簡單代碼的例子(即沒有提供任何東西)。
package main
import (
"fmt"
"github.com/gorilla/mux"
"math"
"net/http"
)
import _ "net/http/pprof"
func SayHello(w http.ResponseWriter, r *http.Request) {
for i := 0; i < 1000000; i++ {
math.Pow(36, 89)
}
fmt.Fprint(w, "Hello!")
}
func main() {
r := mux.NewRouter()
r.HandleFunc("/hello", SayHello)
http.ListenAndServe(":6060", r)
}