File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 "fmt"
66 "os"
77 "path/filepath"
8+ "runtime/pprof"
89 "strings"
910
1011 "github.com/xaionaro-go/binder/tools/pkg/parcelspec"
@@ -14,12 +15,35 @@ import (
1415func main () {
1516 frameworksBase := flag .String ("frameworks-base" , "tools/pkg/3rdparty/frameworks-base" , "Path to the AOSP frameworks-base directory" )
1617 output := flag .String ("output" , "parcelspecs" , "Output directory for YAML spec files" )
18+ cpuProfile := flag .String ("cpuprofile" , "" , "Write CPU profile to file" )
19+ memProfile := flag .String ("memprofile" , "" , "Write memory profile to file" )
1720 flag .Parse ()
1821
22+ if * cpuProfile != "" {
23+ f , err := os .Create (* cpuProfile )
24+ if err != nil {
25+ fmt .Fprintf (os .Stderr , "Error creating CPU profile: %v\n " , err )
26+ os .Exit (1 )
27+ }
28+ defer f .Close ()
29+ pprof .StartCPUProfile (f )
30+ defer pprof .StopCPUProfile ()
31+ }
32+
1933 if err := run (* frameworksBase , * output ); err != nil {
2034 fmt .Fprintf (os .Stderr , "Error: %v\n " , err )
2135 os .Exit (1 )
2236 }
37+
38+ if * memProfile != "" {
39+ f , err := os .Create (* memProfile )
40+ if err != nil {
41+ fmt .Fprintf (os .Stderr , "Error creating memory profile: %v\n " , err )
42+ os .Exit (1 )
43+ }
44+ defer f .Close ()
45+ pprof .WriteHeapProfile (f )
46+ }
2347}
2448
2549func run (
You can’t perform that action at this time.
0 commit comments