profile

package
v0.0.0-...-9ec6d29 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: Apache-2.0, MIT Imports: 7 Imported by: 0

Documentation

Overview

Package profile contains profiling utils.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Start

func Start(opts Opts) func()

Start starts profiling for the given Kinds in opts, and writes the profile data to the corresponding FDs in opts. It returns a function which will stop profiling.

Types

type FDArgs

type FDArgs struct {
	// BlockFD is the file descriptor to write a block profile to.
	// Valid if >=0.
	BlockFD int
	// CPUFD is the file descriptor to write a CPU profile to.
	// Valid if >=0.
	CPUFD int
	// HeapFD is the file descriptor to write a heap profile to.
	// Valid if >=0.
	HeapFD int
	// MutexFD is the file descriptor to write a mutex profile to.
	// Valid if >=0.
	MutexFD int
	// TraceFD is the file descriptor to write a Go execution trace to.
	// Valid if >=0.
	TraceFD int
}

FDArgs are the arguments that describe which profiles to enable and which FDs to write them to. Profiling of a given type will only be enabled if the corresponding FD is >=0.

func (*FDArgs) SetFromFlags

func (fds *FDArgs) SetFromFlags(f *flag.FlagSet)

SetFromFlags sets the FDArgs from the given flags. The default value for each FD is -1.

func (*FDArgs) ToOpts

func (fds *FDArgs) ToOpts() Opts

ToOpts turns FDArgs into an Opts struct which can be passed to Start.

type Kind

type Kind int

Kind is the kind of profiling to perform.

const (
	// Block profile.
	Block Kind = iota
	// CPU profile.
	CPU
	// Heap profile.
	Heap
	// Mutex profile.
	Mutex
	// Trace profile.
	Trace
)

type Opts

type Opts map[Kind]uintptr

Opts is a map of profile Kind to FD.

Jump to

Keyboard shortcuts

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