profiling

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package profiling writes Go runtime profiles when PIG_PROFILE names them.

With PIG_PROFILE unset, Start performs one environment lookup and returns a no-op, so release binaries pay nothing for the capability. With it set, pig profiles the whole process and writes the files on exit:

PIG_PROFILE=cpu,heap pig -p "hello"
PIG_PROFILE=trace PIG_PROFILE_DIR=/tmp/pig-profile pig

Kinds are cpu, heap, allocs, block, mutex, goroutine, and trace. Files go to PIG_PROFILE_DIR (default: the current directory) as pig-<pid>-<kind>.pprof, or pig-<pid>.trace for the execution trace. Read them with `go tool pprof` and `go tool trace`, or run `make profile` from a source checkout.

Index

Constants

This section is empty.

Variables

View Source
var Kinds = []string{"cpu", "heap", "allocs", "block", "mutex", "goroutine", "trace"}

Kinds lists the accepted PIG_PROFILE values in the order they are written.

Functions

func Start

func Start() (stop func())

Start begins the profiles named by PIG_PROFILE and returns the function that stops them and writes every file. The returned function is safe to call more than once; only the first call writes.

func StartWith

func StartWith(spec, dir string, diag io.Writer) (stop func())

StartWith is Start with explicit inputs. Problems are reported to diag and never stop pig: a profile that cannot be written is skipped.

Types

This section is empty.

Jump to

Keyboard shortcuts

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