Documentation
¶
Overview ¶
Package perfcheck provides Go 1.27 goroutineleak profiling, heap growth tracking, goroutine-count settle assertions, and overlay graph topology metrics for tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertHeapGrowthBounded ¶ added in v0.0.3
func AssertHeapGrowthBounded(t testing.TB, before, after HeapSnapshot, maxDeltaKB uint64, label string)
AssertHeapGrowthBounded verifies that live heap growth between before and after does not exceed maxDeltaKB.
func AssertNoGoroutineLeaks ¶
AssertNoGoroutineLeaks uses Go 1.27's GA goroutineleak profile to detect any permanently blocked goroutines whose synchronization primitives are unreachable from live code.
func ForceGC ¶
func ForceGC()
ForceGC runs two GC cycles and yields briefly so finalizers and unreachable goroutines settle.
func RegisterLeakCheck ¶ added in v0.0.3
RegisterLeakCheck schedules AssertNoGoroutineLeaks via t.Cleanup so that when called at the start of a test, it executes strictly AFTER all defers and subsequent t.Cleanup resource teardowns.
Types ¶
type GoroutineBaseline ¶
type GoroutineBaseline struct {
Start int
}
GoroutineBaseline captures the initial goroutine count before a test starts.
func CaptureGoroutines ¶
func CaptureGoroutines() GoroutineBaseline
CaptureGoroutines records the current goroutine count after a brief settle.
func (GoroutineBaseline) AssertSettled ¶
AssertSettled polls until NumGoroutine() <= Start + maxDelta or fails on timeout.
type GraphMetrics ¶
type GraphMetrics struct {
Nodes int
Edges int
Components int
GiantSize int
Diameter int
AvgPathLen float64
MinDegree int
MaxDegree int
AvgDegree float64
IsolatedNodes int
}
GraphMetrics summarizes connected components and shortest-path hop distances.
func AnalyzeGraph ¶
func AnalyzeGraph(adj map[string][]string) GraphMetrics
AnalyzeGraph computes connected components, giant component, exact diameter, and degree stats over an undirected adjacency map (if only directed edges exist, callers should symmetrize first or AnalyzeGraph will symmetrize automatically).
type HeapSnapshot ¶
HeapSnapshot records live heap statistics after GC.
func TakeHeapSnapshot ¶
func TakeHeapSnapshot() HeapSnapshot
TakeHeapSnapshot triggers GC and returns current heap metrics in KiB.