profiler is a tiny wrapper around runtime/pprof for easily profiling Go programs. It allows running one or more profiles (cpu, mem etc.) simultaneously while avoiding boilerplate. The results are dumped to files. This is a rewrite of pkg/profile with the key difference of supporting multiple concurrent profiles.


go get


import ""

func main() {
	// Pass one or more modes: Block, Cpu, Goroutine, Mem, Mutex, ThreadCreate, Trace ...
	p := profiler.New(profiler.Conf{}, profiler.Cpu, profiler.Mem ...)

	// Stuff ...


Optional config

	// Directory path to dump the profile output to. Default is current directory.
	DirPath string

	// Quiet disables info log output.
	Quiet bool

	// NoShutdownHook controls whether the profiling package should
	// hook SIGINT to automatically Stop().
	NoShutdownHook bool

	// MemProfileRate is the rate for the memory profiler. Default is 4096.
	// To include every allocated block in the profile, set MemProfileRate to 1.
	MemProfileRate int

	// MemProfileType = heap or alloc. Default is heap.
	MemProfileType string


View Github