pprof

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

README

Use the pprof tool

Then use the pprof tool to look at the heap profile:

go tool pprof http://localhost:9999/debug/pprof/heap

Or to look at a 30-second CPU profile:

go tool pprof http://localhost:9999/debug/pprof/profile

Or to look at the goroutine blocking profile, after calling runtime.SetBlockProfileRate in your program:

go tool pprof http://localhost:9999/debug/pprof/block

Or to collect a 5-second execution trace:

wget http://localhost:9999/debug/pprof/trace?seconds=5

Trace and upload profile data

curl -X POST --data '{"debug": 0, "gc": 1, "seconds": 10, "profiles": ["profile", "allocs", "heap", "block", "mutex", "goroutine", "threadcreate"], "target": "http://127.0.0.1:9999/debug/pprof/receive"}' http://127.0.0.1:9999/debug/pprof/start

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Default = StdConfig().Build()
)

Functions

This section is empty.

Types

type Config added in v1.0.0

type Config struct {
}

func DefaultConfig added in v1.0.0

func DefaultConfig() *Config

func StdConfig added in v1.0.0

func StdConfig() *Config

func (*Config) Build added in v1.0.0

func (c *Config) Build() *PProf

func (*Config) Path added in v1.0.0

func (c *Config) Path() string

type PProf

type PProf struct {
	// contains filtered or unexported fields
}

func (*PProf) Name

func (pp *PProf) Name() string

func (*PProf) Serve

func (pp *PProf) Serve(ctx context.Context) error

func (*PProf) Shutdown

func (pp *PProf) Shutdown(ctx context.Context) error

func (*PProf) Start added in v1.1.7

func (pp *PProf) Start(ctx *ginserver.Context)

type StartReq added in v1.1.7

type StartReq struct {
	// post pprof file to the target
	Target string `json:"target" binding:"required"`

	// pprof command
	Profiles []string `form:"profiles" binding:"required"`

	// debug=N (all profiles): response format: N = 0: binary (default), N > 0: plaintext
	Debug *int `form:"debug"`

	// gc=N (heap profile): N > 0: run a garbage collection cycle before profiling
	GC *int `form:"gc"`

	// seconds=N (allocs, block, goroutine, heap, mutex, threadcreate profiles): return a delta profile
	// seconds=N (cpu (profile), trace profiles): profile for the given duration
	Seconds *int `form:"seconds"`
}

Jump to

Keyboard shortcuts

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