profiling

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enable

func Enable()

Enable turns on the global profiler.

func Summarize

func Summarize(w io.Writer)

Summarize prints a formatted, hierarchical summary of all timed spans to the writer.

Types

type CobraProfiler

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

CobraProfiler encapsulates profiling state and flag management for Cobra apps.

func NewCobraProfiler

func NewCobraProfiler() *CobraProfiler

NewCobraProfiler creates a new profiler for Cobra integration.

func (*CobraProfiler) AddFlags

func (p *CobraProfiler) AddFlags(cmd *cobra.Command)

AddFlags adds the profiling flags to the given Cobra command.

func (*CobraProfiler) PostRun

func (p *CobraProfiler) PostRun(cmd *cobra.Command, args []string)

PostRun is intended to be used as a Cobra PersistentPostRun hook. It finalizes profiling, writing files and printing summaries.

func (*CobraProfiler) PreRun

func (p *CobraProfiler) PreRun(cmd *cobra.Command, args []string) error

PreRun is intended to be used as a Cobra PersistentPreRunE hook. It initializes profiling based on the flags provided.

type Profiler

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

Profiler manages a profiling session with nested timing spans.

type Stopper

type Stopper interface {
	Stop()
}

Stopper is an interface for stopping a timed span.

func Start

func Start(name string) Stopper

Start begins a new timed span with the given name. It returns a Stopper which must be used to end the span, typically via defer.

Jump to

Keyboard shortcuts

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