profile

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: Apache-2.0, GPL-2.0, GPL-3.0-or-later, + 1 more Imports: 7 Imported by: 0

Documentation

Overview

Package profile implements a uniform interface for getting profiling information from the Go runtime.

Index

Constants

View Source
const (
	ProfileGoroutine    = "goroutine"
	ProfileThreadCreate = "threadcreate"
	ProfileHeap         = "heap"
	ProfileAllocs       = "allocs"
	ProfileBlock        = "block"
	ProfileMutex        = "mutex"
)

The Go runtime's built-in named profiles; to be passed to .Profile().

Variables

This section is empty.

Functions

func Profiles

func Profiles() []string

Profiles returns a list of all profile names that may be passed to .Profile(); both profiles built-in to the Go runtime, and program-added profiles.

Types

type StopFunc

type StopFunc = func() error

func AddProfileFlags

func AddProfileFlags(flags *pflag.FlagSet, prefix string) StopFunc

AddProfileFlags adds flags to a pflag.FlagSet to write any (or all) of the standard profiles to a file, and returns a "stop" function to be called at program shutdown.

func CPU

func CPU(w io.Writer) (StopFunc, error)

CPU arranges to write a CPU profile to the given Writer, and returns a function to be called on shutdown.

func Profile

func Profile(w io.Writer, name string) (StopFunc, error)

Profile arranges to write the given named-profile to the given Writer, and returns a function to be called on shutdown.

CPU profiles are not named profiles; there is a separate .CPU() function for writing CPU profiles.

The Go runtime has several built-in named profiles, and it is possible for programs to create their own named profiles with runtime/pprof.NewProfile().

This package provides ProfileXXX constants for the built-in named profiles, and a .Profiles() function that return the list of all profile names.

func Trace

func Trace(w io.Writer) (StopFunc, error)

Trace arranges to write a trace (https://pkg.go.dev/runtime/trace) to the given Writer, and returns a function to be called on shutdown.

Jump to

Keyboard shortcuts

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