fgprof – github.com/felixge/fgprof Index | Files | Directories

package fgprof

import "github.com/felixge/fgprof"

fgprof is a sampling Go profiler that allows you to analyze On-CPU as well as [Off-CPU](http://www.brendangregg.com/offcpuanalysis.html) (e.g. I/O) time together.

Index

Functions

func Handler

func Handler() http.Handler

Handler returns an http handler that requires a "seconds" query argument and produces a profile over this duration. The optional "format" parameter controls if the output is written in Brendan Gregg's "folded" stack format, or Google's "pprof" format. If no "format" is given, the handler tries to guess the best format based on the http headers.

func Start

func Start(w io.Writer, format Format) func() error

Start begins profiling the goroutines of the program and returns a function that needs to be invoked by the caller to stop the profiling and write the results to w using the given format.

Types

type Format

type Format string
const (
	// FormatFolded is used by Brendan Gregg's FlameGraph utility, see
	// https://github.com/brendangregg/FlameGraph#2-fold-stacks.
	FormatFolded Format = "folded"
	// FormatPprof is used by Google's pprof utility, see
	// https://github.com/google/pprof/blob/master/proto/README.md.
	FormatPprof Format = "pprof"
)

Source Files

fgprof.go format.go handler.go pprof.go

Directories

PathSynopsis
example
Version
v0.9.0
Published
Jun 24, 2020
Platform
windows/amd64
Imports
8 packages
Last checked
3 seconds ago

Tools for package owners.