Skip to content

Instantly share code, notes, and snippets.

@0xc0d
Created October 27, 2020 14:58
Show Gist options
  • Save 0xc0d/fdfac34dcbe82c51a1e387045ae8b0fc to your computer and use it in GitHub Desktop.
Save 0xc0d/fdfac34dcbe82c51a1e387045ae8b0fc to your computer and use it in GitHub Desktop.
Different profiles in pkg/profile
// CPUProfile enables cpu profiling. Note: Default is CPU
defer profile.Start(profile.CPUProfile).Stop()
// GoroutineProfile enables goroutine profiling.
// It returns all Goroutines alive when defer occurs.
defer profile.Start(profile.GoroutineProfile).Stop()
// BlockProfile enables block (contention) profiling.
defer profile.Start(profile.BlockProfile).Stop()
// ThreadcreationProfile enables thread creation profiling.
defer profile.Start(profile.ThreadcreationProfile).Stop()
// MemProfileHeap changes which type of memory profiling to
// profile the heap.
defer profile.Start(profile.MemProfileHeap).Stop()
// MemProfileAllocs changes which type of memory to profile
// allocations.
defer profile.Start(profile.MemProfileAllocs).Stop()
// MutexProfile enables mutex profiling.
defer profile.Start(profile.MutexProfile).Stop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment