profiling

package
v1.86.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package profiling provides helpers for CPU and memory profiling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartPprofServer added in v1.86.0

func StartPprofServer(ctx context.Context, addr string) error

StartPprofServer starts an HTTP server exposing Go runtime profiling endpoints at /debug/pprof/ on the given addr. It binds the listener synchronously and returns an error if the address is unavailable. The server runs in a background goroutine and shuts down when ctx is cancelled. addr must be a TCP host:port address (e.g. "127.0.0.1:6060"); unix://, npipe://, and fd:// schemes are not supported. Prefer a loopback address over a bare port (":6060") — the latter binds all interfaces, exposing process memory and arguments to the network.

Types

type Stop

type Stop func() error

Stop is a function returned by Start that stops profiling and flushes any buffered data. It must be called (typically via defer) when the profiled section of code completes.

func Start

func Start(cpuProfile, memProfile string) (Stop, error)

Start begins CPU and/or memory profiling based on the provided file paths. Pass an empty string to skip the corresponding profile. The returned Stop function must be called to finalise the profiles.

Jump to

Keyboard shortcuts

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