Skip to content

Commit

Permalink
Add heap profiling.
Browse files Browse the repository at this point in the history
  • Loading branch information
anupcshan committed Mar 23, 2015
1 parent 1c1556a commit 1b3486e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ _testmain.go

# Profile files
*.prof
*.heap
21 changes: 16 additions & 5 deletions main/buddyfs/buddyfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
var storeType = flag.String("store", "p2p",
"Type of backing store for filesystem. Options: mem|gkv|p2p")

var profile = flag.Bool("profile", true, "Enable profiling output")

var PORT uint = 9000
var TIMEOUT time.Duration = time.Duration(20 * time.Millisecond)

Expand Down Expand Up @@ -97,12 +99,21 @@ func main() {
}
defer c.Close()

f, err := os.Create("buddyfs.prof")
if err != nil {
log.Fatal(err)
if *profile {
f, err := os.Create("buddyfs.prof")
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()

heapproff, err := os.Create("buddyfs.heap")
if err != nil {
log.Fatal(err)
}

defer pprof.WriteHeapProfile(heapproff)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()

var kvStore gobuddyfs.KVStore
var cleanup func()
Expand Down

0 comments on commit 1b3486e

Please sign in to comment.