cpuprofile

package
v1.1.0-beta.0...-9958228 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefProfileDuration = time.Second

DefProfileDuration exports for testing.

Functions

func ProfileHTTPHandler

func ProfileHTTPHandler(w http.ResponseWriter, r *http.Request)

ProfileHTTPHandler is same as pprof.Profile. The difference is ProfileHTTPHandler uses cpuprofile.GetCPUProfile to fetch profile data.

func Register

func Register(ch ProfileConsumer)

Register register a ProfileConsumer into the global CPU profiler. Normally, the registered ProfileConsumer will receive the cpu profile data per second. If the ProfileConsumer (channel) is full, the latest cpu profile data will not be sent to it. This function is thread-safe. WARN: ProfileConsumer should not be closed before unregister.

func StartCPUProfiler

func StartCPUProfiler() error

StartCPUProfiler uses to start to run the global parallelCPUProfiler.

func StopCPUProfiler

func StopCPUProfiler()

StopCPUProfiler uses to stop the global parallelCPUProfiler.

func Unregister

func Unregister(ch ProfileConsumer)

Unregister unregister a ProfileConsumer from the global CPU profiler. The unregistered ProfileConsumer won't receive the cpu profile data any more. This function is thread-safe.

Types

type Collector

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

Collector is a cpu profile collector, it collect cpu profile data from globalCPUProfiler.

func NewCollector

func NewCollector() *Collector

NewCollector returns a new NewCollector.

func (*Collector) StartCPUProfile

func (pc *Collector) StartCPUProfile(w io.Writer) error

StartCPUProfile is a substitute for the `pprof.StartCPUProfile` function. You should use this function instead of `pprof.StartCPUProfile`. Otherwise you may fail, or affect the TopSQL feature and pprof profile HTTP API . WARN: this function is not thread-safe.

func (*Collector) StopCPUProfile

func (pc *Collector) StopCPUProfile() error

StopCPUProfile is a substitute for the `pprof.StopCPUProfile` function. WARN: this function is not thread-safe.

type ProfileConsumer

type ProfileConsumer = chan *ProfileData

ProfileConsumer is a channel that will receive profiling data from the CPU profiler periodically. If the channel is full, then the channel won't receive the latest profile data until it is not blocked.

type ProfileData

type ProfileData struct {
	Data  *bytes.Buffer
	Error error
}

ProfileData contains the cpu profile data between the start and end time, usually the interval between start and end is about 1 second.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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