aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorShinichiro Hamaji <shinichiro.hamaji@gmail.com>2015-04-12 04:17:10 +0900
committerShinichiro Hamaji <shinichiro.hamaji@gmail.com>2015-04-12 04:17:10 +0900
commit5ff9b346796132178ac29b3b288915e77d3e3942 (patch)
tree1b142b33c8c50cd011e92861b6a6896cc324d927 /main.go
parentc4c98106620069867625123d0a4fd9fc4addfeb5 (diff)
downloadandroid_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.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/main.go b/main.go
index 74a28fb..8a6c78e 100644
--- a/main.go
+++ b/main.go
@@ -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()