goprofiler

module
v0.0.0-...-e1e7934 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2018 License: MIT

README

Golang profiling utility

GoDoc

Introduction

Simple profiling support package for Go.

Inspired by Dave Cheney's library, with extra functionality and automation.

The library can take CPU, Memory, Block, Mutex and Goroutine profiles. It can either take a single snapshot, or can take snapshots at regular intervals.

Installation

go get github.com/quipo/goprofiler/profiler

Sample usage

package main

import (
	"time"

	"github.com/quipo/goprofiler/profiler"
)

func main() {
	pprofConf := profiler.Config{
		Prefix: "/tmp/myapp.",
		CPU: true,
		Memory: true,
		Block: false,
		Goroutine: false,
		Mutex: false,
		Interval: "15s",      // one snapshot every 15 seconds,
		CPUProfileRate: 100,  // collect 100 CPU profiling samples per second
		MemoryProfileRate: 1, // collect information about all allocations
		MutexProfileRate: 1,  // collect information about all blocking events
	}
	prof := profiler.NewProfiler(pprofConf)
	go prof.Run()
	
	// your app's code here...

	// you can take a snapshot at any point in the code:
	prof.TakeSnapshot()

	// take one last snapshot and clean resources
	prof.Stop()
}

FlameGraph links:

Author

Lorenzo Alberton

See LICENSE document

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL