diff options
author | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-04-12 04:17:10 +0900 |
---|---|---|
committer | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-04-12 04:17:10 +0900 |
commit | 5ff9b346796132178ac29b3b288915e77d3e3942 (patch) | |
tree | 1b142b33c8c50cd011e92861b6a6896cc324d927 /main.go | |
parent | c4c98106620069867625123d0a4fd9fc4addfeb5 (diff) | |
download | android_build_kati-5ff9b346796132178ac29b3b288915e77d3e3942.tar.gz android_build_kati-5ff9b346796132178ac29b3b288915e77d3e3942.tar.bz2 android_build_kati-5ff9b346796132178ac29b3b288915e77d3e3942.zip |
Add --kati_heapprofile flag
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -13,6 +13,7 @@ var ( makefileFlag string dryRunFlag bool cpuprofile string + heapprofile string ) func parseFlags() { @@ -22,6 +23,7 @@ func parseFlags() { flag.BoolVar(&dryRunFlag, "n", false, "Only print the commands that would be executed") flag.StringVar(&cpuprofile, "kati_cpuprofile", "", "write cpu profile to `file`") + flag.StringVar(&heapprofile, "kati_heapprofile", "", "write heap profile to `file`") flag.Parse() } @@ -66,6 +68,16 @@ SHELL:=/bin/sh return mk } +func maybeWriteHeapProfile() { + if heapprofile != "" { + f, err := os.Create(heapprofile) + if err != nil { + panic(err) + } + pprof.WriteHeapProfile(f) + } +} + func main() { parseFlags() if cpuprofile != "" { @@ -76,6 +88,7 @@ func main() { pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() } + defer maybeWriteHeapProfile() clvars, targets := parseCommandLine() |