Add an option to gather CPU profile.
Bug: 172923994 Test: internal Change-Id: I43e6121855e909eaca2204a811f12174fb8b6b5f
This commit is contained in:
@@ -28,6 +28,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
|
"runtime/pprof"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -52,6 +53,7 @@ var (
|
|||||||
outputTop = flag.String("outdir", "", "write output files into this directory hierarchy")
|
outputTop = flag.String("outdir", "", "write output files into this directory hierarchy")
|
||||||
launcher = flag.String("launcher", "", "generated launcher path. If set, the non-flag argument is _product_name_")
|
launcher = flag.String("launcher", "", "generated launcher path. If set, the non-flag argument is _product_name_")
|
||||||
printProductConfigMap = flag.Bool("print_product_config_map", false, "print product config map and exit")
|
printProductConfigMap = flag.Bool("print_product_config_map", false, "print product config map and exit")
|
||||||
|
cpuProfile = flag.String("cpu_profile", "", "write cpu profile to file")
|
||||||
traceCalls = flag.Bool("trace_calls", false, "trace function calls")
|
traceCalls = flag.Bool("trace_calls", false, "trace function calls")
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -122,6 +124,14 @@ func main() {
|
|||||||
tracedVariables = strings.Split(*traceVar, ",")
|
tracedVariables = strings.Split(*traceVar, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if *cpuProfile != "" {
|
||||||
|
f, err := os.Create(*cpuProfile)
|
||||||
|
if err != nil {
|
||||||
|
quit(err)
|
||||||
|
}
|
||||||
|
pprof.StartCPUProfile(f)
|
||||||
|
defer pprof.StopCPUProfile()
|
||||||
|
}
|
||||||
// Find out global variables
|
// Find out global variables
|
||||||
getConfigVariables()
|
getConfigVariables()
|
||||||
getSoongVariables()
|
getSoongVariables()
|
||||||
|
Reference in New Issue
Block a user