From cad3da337a5c040ebcbdd0d02363f767d3300464 Mon Sep 17 00:00:00 2001 From: astaxie Date: Fri, 15 Aug 2014 15:17:11 +0800 Subject: [PATCH] toolbox: fix the program name --- toolbox/profile.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/toolbox/profile.go b/toolbox/profile.go index da14f0b0..3283fd4d 100644 --- a/toolbox/profile.go +++ b/toolbox/profile.go @@ -15,6 +15,7 @@ import ( "log" "net/http" "os" + "path" "runtime" "runtime/debug" "runtime/pprof" @@ -64,7 +65,8 @@ func MemProf(w io.Writer) { pprof.WriteHeapProfile(f) f.Close() fmt.Fprintf(w, "create heap profile %s \n", filename) - fmt.Fprintf(w, "Now you can use this to check it: go tool pprof %s\n", filename) + _, fl := path.Split(os.Args[0]) + fmt.Fprintf(w, "Now you can use this to check it: go tool pprof %s %s\n", fl, filename) } } @@ -85,7 +87,8 @@ func GetCPUProfile(rw http.ResponseWriter) { time.Sleep(time.Duration(sec) * time.Second) pprof.StopCPUProfile() fmt.Fprintf(rw, "create cpu profile %s \n", filename) - fmt.Fprintf(rw, "Now you can use this to check it: go tool pprof %s\n", filename) + _, fl := path.Split(os.Args[0]) + fmt.Fprintf(rw, "Now you can use this to check it: go tool pprof %s %s\n", fl, filename) } // print gc information to io.Writer