profile

package
v0.0.0-...-88b07f2 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProfilingCpu

func ProfilingCpu(runnable Runnable, writer io.Writer) (err error)

ProfilingCpu enables CPU profiling for the current process if no writer is provided then profiling will not be started

func ProfilingMem

func ProfilingMem(runnable Runnable, writer io.Writer, rates ...int) (err error)

ProfilingMem enables memory profiling for current process if no writer is provided then profiling will not be started

func Tracing

func Tracing(runnable Runnable, writer io.Writer) (err error)

Tracing enables tracing for the current process if no writer is provided then profiling will not be started

Types

type Option

type Option func(prof *Profile)

Option is a type used to provide optional profiling/tracing writers

func WithCpuWriter

func WithCpuWriter(writer io.Writer) Option

WithCpuWriter used to set an io.Writer for CPU profiling in Profile

func WithMemProfileRate

func WithMemProfileRate(rate int) Option

WithMemProfileRate used to set fraction of memory allocations that are recorded and reported in the memory profile see runtime.MemProfileRate

func WithMemWriter

func WithMemWriter(writer io.Writer) Option

WithMemWriter used to set an io.Writer for memory profiling in Profile

func WithTraceWriter

func WithTraceWriter(writer io.Writer) Option

WithTraceWriter used to set an io.Writer for tracing in Profile

type Profile

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

Profile is a performance analysis tool that supports CPU, memory profiling and runtime activity tracing

runtime profiling/tracing data will write in the format expected by the pprof visualization tool.

func New

func New(options ...Option) *Profile

New creates a new profile with optional writers

func (*Profile) Run

func (prof *Profile) Run(runnable Runnable) (err error)

Run execute code that requires performance analysis and write data at the end of execution

each profiling/tracing is optional, and if no io.Writer is provided, no profiling/tracing will be performed

type Runnable

type Runnable func() error

Runnable represents a block of executable code

Jump to

Keyboard shortcuts

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