Skip to content

Commit

Permalink
Fix MemProfileAllocs and MemProfileHeap options
Browse files Browse the repository at this point in the history
Fixes #55
  • Loading branch information
davecheney committed Jun 12, 2020
1 parent e3db4c8 commit 3704c8d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
10 changes: 10 additions & 0 deletions example_test.go
Expand Up @@ -29,6 +29,16 @@ func ExampleMemProfileRate() {
defer profile.Start(profile.MemProfileRate(2048)).Stop()
}

func ExampleMemProfileHeap() {
// use heap memory profiling.
defer profile.Start(profile.MemProfileHeap).Stop()
}

func ExampleMemProfileAllocs() {
// use allocs memory profiling.
defer profile.Start(profile.MemProfileAllocs).Stop()
}

func ExampleProfilePath() {
// set the location that the profile will be written to
defer profile.Start(profile.ProfilePath(os.Getenv("HOME"))).Stop()
Expand Down
16 changes: 6 additions & 10 deletions profile.go
Expand Up @@ -90,20 +90,16 @@ func MemProfileRate(rate int) func(*Profile) {

// MemProfileHeap changes which type of memory profiling to profile
// the heap.
func MemProfileHeap() func(*Profile) {
return func(p *Profile) {
p.memProfileType = "heap"
p.mode = memMode
}
func MemProfileHeap(p *Profile) {
p.memProfileType = "heap"
p.mode = memMode
}

// MemProfileAllocs changes which type of memory to profile
// allocations.
func MemProfileAllocs() func(*Profile) {
return func(p *Profile) {
p.memProfileType = "allocs"
p.mode = memMode
}
func MemProfileAllocs(p *Profile) {
p.memProfileType = "allocs"
p.mode = memMode
}

// MutexProfile enables mutex profiling.
Expand Down

0 comments on commit 3704c8d

Please sign in to comment.