perf

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package perf is lightweight, opt-in instrumentation: named counters (Count) and timers (Record/Time) that flush to a log for the headless harness and the perf baselines. It is disabled by default in production.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count(name string, delta int64)

Count increments a named counter by delta.

func EnableForTest added in v0.0.12

func EnableForTest() func()

EnableForTest forces perf collection on (and disables periodic logging). It returns a restore function to reset prior settings.

func Enabled

func Enabled() bool

Enabled reports whether profiling is enabled.

func Flush added in v0.0.12

func Flush(reason string)

Flush logs a summary of current stats/counters immediately. If reason is provided, it is included in the log prefix.

func Init added in v0.0.20

func Init()

Init reads the AMUX_PROFILE / AMUX_PROFILE_INTERVAL_MS environment and arms profiling accordingly. The app calls this explicitly during construction; it is idempotent, so library users and tests may also call it directly.

func Record

func Record(name string, d time.Duration)

Record captures a duration sample for the given name.

func Reset added in v0.0.20

func Reset()

Reset clears all recorded stats and counters and re-reads the environment. Intended for tests that toggle AMUX_PROFILE between cases.

func Snapshot added in v0.0.12

func Snapshot() ([]StatSnapshot, []CounterSnapshot)

Snapshot returns current perf stats/counters and resets them.

func Time

func Time(name string) func()

Time returns a function that records elapsed time when invoked.

Types

type CounterSnapshot added in v0.0.12

type CounterSnapshot struct {
	Name  string
	Value int64
}

CounterSnapshot captures perf counters for diagnostics/tests.

type StatSnapshot added in v0.0.12

type StatSnapshot struct {
	Name  string
	Count int64
	Avg   time.Duration
	Min   time.Duration
	Max   time.Duration
	P95   time.Duration
}

StatSnapshot captures perf duration stats for diagnostics/tests.

Jump to

Keyboard shortcuts

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