pprof_demo.go 487 B

12345678910111213141516171819202122232425262728293031
  1. package main
  2. import (
  3. "log"
  4. "net/http"
  5. _ "net/http/pprof"
  6. "os"
  7. "runtime/pprof"
  8. "time"
  9. )
  10. type pprofDemo struct {
  11. }
  12. func (demo *pprofDemo) start() {
  13. // Http pprof
  14. // http://127.0.0.1:8000/debug/pprof
  15. //hello := func(w http.ResponseWriter, req *http.Request) {
  16. // _, _ = w.Write([]byte("Hello, world!"))
  17. //}
  18. //http.HandleFunc("/", hello)
  19. if err := http.ListenAndServe(":8000", nil); err != nil {
  20. log.Fatal(err)
  21. }
  22. }
  23. func main() {
  24. demo := new(pprofDemo)
  25. demo.start()
  26. }