-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Milestone
Description
Running godoc on OS X 10.6.7 with the changes shown below, the CPU profile only lists
calls to __cgo_allocate. This has been reported on the list, too.
$ gopprof godoc godoc.prof
Welcome to pprof! For help, type 'help'.
(pprof) top10
Total: 7200 samples
7200 100.0% 100.0% 7200 100.0% __cgo_allocate
diff -r b295b8bda20b src/cmd/godoc/godoc.go
--- a/src/cmd/godoc/godoc.go Sun Jun 26 11:24:28 2011 +1000
+++ b/src/cmd/godoc/godoc.go Mon Jun 27 08:41:25 2011 +1000
@@ -20,6 +20,7 @@
"path/filepath"
"regexp"
"runtime"
+ "runtime/pprof"
"sort"
"strings"
"template"
@@ -1279,6 +1280,7 @@
log.Printf("before GC: bytes = %d footprint = %d", runtime.MemStats.HeapAlloc, runtime.MemStats.Sys)
runtime.GC()
log.Printf("after GC: bytes = %d footprint = %d", runtime.MemStats.HeapAlloc, runtime.MemStats.Sys)
+ pprof.StopCPUProfile()
}
var delay int64 = 60 * 1e9 // by default, try every 60s
if *testDir != "" {
diff -r b295b8bda20b src/cmd/godoc/main.go
--- a/src/cmd/godoc/main.go Sun Jun 26 11:24:28 2011 +1000
+++ b/src/cmd/godoc/main.go Mon Jun 27 08:41:25 2011 +1000
@@ -39,6 +39,7 @@
"path/filepath"
"regexp"
"runtime"
+ "runtime/pprof"
"strings"
"time"
)
@@ -218,10 +219,21 @@
}
+var cpuprofile = flag.String("cpuprofile", "", "")
+
func main() {
flag.Usage = usage
flag.Parse()
+ if *cpuprofile != "" {
+ f, err := os.Create(*cpuprofile)
+ if err != nil {
+ log.Fatal(err)
+ }
+ pprof.StartCPUProfile(f)
+ defer pprof.StopCPUProfile()
+ }
+
// Determine file system to use.
// TODO(gri) Complete this - for now we only have one.
fs = OSReactions are currently unavailable