perfcheck

package
v0.0.0-dev3 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: BSD-2-Clause Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 AssertNoGoroutineLeaks

func AssertNoGoroutineLeaks(t testing.TB)

AssertNoGoroutineLeaks uses Go 1.27's GA goroutineleak profile to detect any permanently blocked goroutines whose synchronization primitives are unreachable from live code.

func EnvInt

func EnvInt(key string, def int) int

EnvInt returns the integer value of env var key, or def if unset or invalid.

func ForceGC

func ForceGC()

ForceGC runs two GC cycles and yields briefly so finalizers and unreachable goroutines settle.

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

func (b GoroutineBaseline) AssertSettled(t testing.TB, maxDelta int, timeout time.Duration) int

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

type HeapSnapshot struct {
	HeapAllocKB uint64
	HeapInuseKB uint64
	HeapObjects uint64
}

HeapSnapshot records live heap statistics after GC.

func TakeHeapSnapshot

func TakeHeapSnapshot() HeapSnapshot

TakeHeapSnapshot triggers GC and returns current heap metrics in KiB.

Jump to

Keyboard shortcuts

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