profiling

package
v0.1.0-preview.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package profiling supplies opt-in presentation diagnostics. Its wall-clock samples never drive gameplay, input acceptance, or animation decisions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Begin

func Begin() time.Time

Begin returns zero when disabled, avoiding wall-time reads in ordinary play.

func Count

func Count(counter Counter)

Count records work only while diagnostics are enabled.

func Disable

func Disable()

Disable stops collection without discarding a caller's completed snapshot.

func EndDraw

func EndDraw(start time.Time)

EndDraw records a content-rendered Draw, excluding the frame-limiter early return.

func EndReadySelection

func EndReadySelection(start time.Time)

EndReadySelection measures latest accepted arrow selection to its next Draw. Multiple accepted moves before a Draw coalesce; this is not OS keypress latency.

func EndUpdate

func EndUpdate(start time.Time)

EndUpdate records the complete application Update, including debug processing.

func SetGauge

func SetGauge(counter Counter, value uint64)

SetGauge publishes resource accounting only while diagnostics are enabled.

Types

type Counter

type Counter int

Counter identifies measured resource work, independently of sampled CPU time.

const (
	FontCreates Counter = iota
	ProvisionFontRebuilds
	TextHits
	TextMisses
	TextEvictions
	ReadyRebuilds
	ReadySelections
	FontSourceParses
	TextLayoutBuilds
	TextCacheEntries
	TextCacheBytes
	TextCachePeakBytes
	TextCacheBypasses
	DitherBuilds
	OuterDitherBuilds
)

Resource-work counters distinguish rebuilds from ordinary cached composition.

type DurationSummary

type DurationSummary struct {
	Count   uint64  `json:"count"`
	Samples int     `json:"recentSamples"`
	P50Ms   float64 `json:"p50Ms"`
	P95Ms   float64 `json:"p95Ms"`
	P99Ms   float64 `json:"p99Ms"`
	MaxMs   float64 `json:"recentMaxMs"`
}

DurationSummary reports cumulative sample count and recent wall-time quantiles. Concurrent reads are an approximate rolling window, not an atomic frame trace.

type Metrics

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

Metrics holds bounded samples and counters safe to read from the profile server.

func Enable

func Enable() *Metrics

Enable starts a fresh diagnostic session; production enables it at startup.

func (*Metrics) Snapshot

func (metrics *Metrics) Snapshot() Snapshot

Snapshot allocates/serializes only on request, not inside the frame loop.

type Snapshot

type Snapshot struct {
	Counters               map[string]uint64 `json:"counters"`
	Update                 DurationSummary   `json:"update"`
	ContentDraw            DurationSummary   `json:"contentDraw"`
	ReadySelectionNextDraw DurationSummary   `json:"readySelectionNextDraw"`
}

Snapshot contains only counters/timing storage, never live game state.

Jump to

Keyboard shortcuts

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