cad3da33 by astaxie

toolbox: fix the program name

1 parent 3969cd3b
...@@ -15,6 +15,7 @@ import ( ...@@ -15,6 +15,7 @@ import (
15 "log" 15 "log"
16 "net/http" 16 "net/http"
17 "os" 17 "os"
18 "path"
18 "runtime" 19 "runtime"
19 "runtime/debug" 20 "runtime/debug"
20 "runtime/pprof" 21 "runtime/pprof"
...@@ -64,7 +65,8 @@ func MemProf(w io.Writer) { ...@@ -64,7 +65,8 @@ func MemProf(w io.Writer) {
64 pprof.WriteHeapProfile(f) 65 pprof.WriteHeapProfile(f)
65 f.Close() 66 f.Close()
66 fmt.Fprintf(w, "create heap profile %s \n", filename) 67 fmt.Fprintf(w, "create heap profile %s \n", filename)
67 fmt.Fprintf(w, "Now you can use this to check it: go tool pprof <program> %s\n", filename) 68 _, fl := path.Split(os.Args[0])
69 fmt.Fprintf(w, "Now you can use this to check it: go tool pprof %s %s\n", fl, filename)
68 } 70 }
69 } 71 }
70 72
...@@ -85,7 +87,8 @@ func GetCPUProfile(rw http.ResponseWriter) { ...@@ -85,7 +87,8 @@ func GetCPUProfile(rw http.ResponseWriter) {
85 time.Sleep(time.Duration(sec) * time.Second) 87 time.Sleep(time.Duration(sec) * time.Second)
86 pprof.StopCPUProfile() 88 pprof.StopCPUProfile()
87 fmt.Fprintf(rw, "create cpu profile %s \n", filename) 89 fmt.Fprintf(rw, "create cpu profile %s \n", filename)
88 fmt.Fprintf(rw, "Now you can use this to check it: go tool pprof <program> %s\n", filename) 90 _, fl := path.Split(os.Args[0])
91 fmt.Fprintf(rw, "Now you can use this to check it: go tool pprof %s %s\n", fl, filename)
89 } 92 }
90 93
91 // print gc information to io.Writer 94 // print gc information to io.Writer
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!